webpack-cli icon indicating copy to clipboard operation
webpack-cli copied to clipboard

Give examples of syntax for complex command options

Open c100k opened this issue 2 years ago • 3 comments

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

c100k avatar May 13 '22 22:05 c100k

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

alexander-akait avatar May 14 '22 08:05 alexander-akait

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 ?

c100k avatar May 14 '22 09:05 c100k

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

snitin315 avatar Jun 14 '22 07:06 snitin315

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.

webpack-bot avatar Dec 13 '22 09:12 webpack-bot

Issue was closed because of inactivity.

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

webpack-bot avatar Dec 28 '22 11:12 webpack-bot