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
< 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?