M
M
Michael R.2020-10-15 10:55:47
JavaScript
Michael R., 2020-10-15 10:55:47

Webpack how to read cli options?

Greetings!

I am building the project through webpack, trying to get the cli parameters of the string that I pass during the build. Using the yargs module guide https://www.npmjs.com/package/yargs :

const {argv} = require('yargs');
console.log(argv);

$ npm run start --test=4

{
  _: [],
  cache: null,
  bail: null,
  profile: null,
  color: { level: 3, hasBasic: true, has256: true, has16m: true },
  colors: { level: 3, hasBasic: true, has256: true, has16m: true },
  liveReload: true,
  'live-reload': true,
  serveIndex: true,
  'serve-index': true,
  inline: true,
  info: true,
  mode: 'development',
  'info-verbosity': 'info',
  infoVerbosity: 'info',
  'client-log-level': 'info',
  clientLogLevel: 'info',
  host: 'localhost',
  '$0': 'node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
}

The parameter I passed was not found, what should I do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-10-15
@Mike_Ro

And so:
npm run start -- -test=4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question