Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Support argv as second config param #79

Open
HaNdTriX opened this issue Feb 28, 2018 · 8 comments
Open

Support argv as second config param #79

HaNdTriX opened this issue Feb 28, 2018 · 8 comments

Comments

@HaNdTriX
Copy link

HaNdTriX commented Feb 28, 2018

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
@HaNdTriX
Copy link
Author

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

@mzealey
Copy link

mzealey commented Jan 10, 2019

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

@eugef
Copy link

eugef commented Jul 9, 2019

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.

@HaNdTriX
Copy link
Author

HaNdTriX commented Jul 9, 2019

@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.

@HaNdTriX HaNdTriX reopened this Jul 9, 2019
@eugef
Copy link

eugef commented Jul 9, 2019

Are you using smth else instead?

@HaNdTriX
Copy link
Author

HaNdTriX commented Jul 9, 2019

Nope.

@pago
Copy link
Contributor

pago commented Jul 12, 2019

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

@iorrah
Copy link

iorrah commented Jul 21, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants