trivago/parallel-webpack

Support argv as second config param

HaNdTriX opened this issue ยท 8 comments

Explain the problem

Sometimes a developer wants to access webpacks internal command line options in his config.

Expected Behaviour

The config function should pass two params into the config function:

  • An environment as the first parameter. See the environment options CLI documentation for syntax examples.
  • An options map (argv) as the second parameter. This describes the options passed to webpack, with keys such as output-filename and optimize-minimize.

source

Actual Behaviour

parallel-webpack omits the second param (argv).

Provide your webpack config

module.exports = (env, argv) => {
     console.log('isEnvSet', !!env)
     console.log('isArgvSet', !!argv)
     return {}
}

Steps to reproduce

Use the config above and run:

parallel-webpack --config=webpack.config.js

Provide your Environment details

  • Node version: v9.1.0
  • Operating System: MacOS 10.13.3
  • webpack version: 3.11.0
  • parallel-webpack version: 2.3.0

closing for know, unit I got additional infos on the topic.

This is also an issue for me. Webpack passes an object containing the argv (eg {mode: 'production'}) as 2nd argument to module.exports

eugef commented

I also have the same issue - not able to access argv.mode when using like this:

module.exports = (env, argv) => {
}

@HaNdTriX are there any planms to fix it? As it is impossible to simply replace webpack with parallel-webpack in cli.

@eugef I am not the author/contributor of this package.

Nevertheless, I reopen this issue for you guys. I am not using parallel-webpack anymore.

eugef commented

Are you using smth else instead?

Nope.

pago commented

I'm happy to merge a PR that adjusts this according to your needs.

This also works:

package.json

"scripts": {
  "start": "parallel-webpack -- --foo=bar"
}

webpack.config.js

const parser = require('yargs').parse;

const parsedArgv = parser(process.argv);
console.log(parsedArgv.foo); // bar