webpack/webpack-cli

Give examples of syntax for complex command options

c100k opened this issue · 5 comments

c100k commented

Is your feature request related to a problem? Please describe.

It's very hard to translate a webpack.config.js into a single CLI command. For simple options like --mode=production it's pretty straightforward.

But it gets more complicated for options representing a complex object or an array. Let's take resolve.extensions as an example. In webpack.config.js, it's easy : extensions: ['.ts', '.tsx'].

For the CLI, OPTIONS.md says :

--resolve-extensions <value...> Extension added to the request when trying to find the file.

What is the expected shape of <value...> ?

  • --resolve-extensions=.ts,.tsx ?
  • --resolve-extensions=[.ts,.tsx] ?
  • --resolve-extensions=.ts --resolve-extensions=.tsx ?

For more complex settings, it's even more complicated. How to represent the following entry in JS :

alias: {
    '@sdk$': path.join(process.cwd(), 'src', 'sdk'),
},

with the following CLI option --resolve-alias-name <value...> Request to be redirected. ?

Describe the solution you'd like

The ideal would be to have an example for each entry in OPTIONS.md. Or maybe at least have a global section presenting how each JS data type translates into CLI options.

Describe alternatives you've considered

To be honest, it's guess and try because I haven't found any documentation about this.

Additional context

We use standard CLI syntax, it will be very large output if we put examples for an each option... Also we get supported CLI options from webpack.

Actually <value...> means multiple string values, i.e. --resolve-extensions=.ts --resolve-extensions=.tsx is valid

c100k commented

it will be very large output if we put examples for an each option

Indeed I can understand that. What would be the syntax for key/value entries like resolve.alias, module.rules then ?

For that we have --resolve-alias-name <value> --resolve-alias-alias <value> You can see all the available options here

This issue had no activity for at least half a year.

It's subject to automatic issue closing if there is no activity in the next 15 days.

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.