Reputation: 221
I'm trying to create a webpack setup but can't manage to make it work with the environment variables. I have read the doc more than 10 times but can't find the solution.
My package json has this script:
"build": "webpack --config webpack.config.js --env.MODE=production "
But when I'm running it, node is telling me:
webpack: Unknown argument: --env.MODE=production
Usage: webpack --config <path to webpack configuration file> e.g. ./webpack.config.js
Description: Provide path to a webpack configuration file
Documentation: https://webpack.js.org/configuration/
EDIT: I finally found the solution. The webpack-ci installed version was "webpack-cli": "^4.0.0-beta.2". I downgraded it and it's now working fine.
Upvotes: 8
Views: 11665
Reputation: 8047
Just use with spacing..
"build": "webpack --mode=production --config webpack.config.js --env MODE=production"
Now you can parse it like:
module.exports = ({ MODE }, { mode }) => {...}
Have a good day!
Upvotes: 6