How should webpack pass custom parameters?

1, the effect you want to achieve
the script configuration in package is as follows:

"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js"

what you need to achieve now is to run

npm run dev <some code>

get custom parameters
for example:

npm run dev --name test

get test in code

< hr >

2, attempts made

  • install cross-env
  • use-- key value to pass parameters as follows
npm run dev --name test
  • use env as the prefix parameter
npm run dev --env.name test

I get the value of test in all of the above ways, but I will report an error

.

the error is as follows

clipboard.png

< hr >

3. Guess and doubt
look at this error. I think the reason is that the passed key [name] is identified when passing parameters, but the demo is not recognized as the value of the previous key.
can this problem be avoided if parameters can be passed directly to the environment instead of webpack-dev-server?
but so far, a lot of information has been checked and it is said that parameters can be passed. The number is followed by the value
. Why is there such an error
? how to solve it?

Jul.21,2021

https://stackoverflow.com/que.

npm run dev -- -- name=test
< hr >

build/webpack.dev.conf.js

console.log(process.argv[process.argv.length - 1]);

can use environment variables, which requires the support of the webpack.DefinePlugin plug-in


this problem is finally solved by passing the parameters that come with webpack to the configuration file. For more information, please see to explain the webpack configuration in vue-cli

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eabd33-46dca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eabd33-46dca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?