I have a simple webpack.config.js
module.exports = { entry: "./app.js", output: { filename: "bundle.js" }, } And I want to pass the values for entryand output through command line arguments. Is that possible and how would I do that?
webpack.config.js can also exports a function of env which can return a conf object. You can therefore have a webpack config like:
module.exports = env => { return { entry: env === "production" ? "./app.js": "app-dev.js", output: { filename: "bundle.js" }, } }; and then call webpack from command-line (or package.json) like this:
webpack --env=production
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With