PatrickJS-starter
PatrickJS-starter copied to clipboard
Changing NODE_ENV or HOST variables in webpack from npm command line
I want to use webpack.dev.js file for both development on my local machine and for AWS.
I want to write some logic in my service based on the ENV or host. e.g.
if(process.env.HOST=== 'localhost'){
-- Add some headers here
}else{
--- Do not add headers
}
My configuration for webpack.dev.js is :
const ENV = process.env.ENV = process.env.NODE_ENV = 'development';
const HOST = process.env.HOST || 'localhost';
How can I change NODE_ENV or HOST when doing the build using 'webpack --config config/webpack.dev.js --progress --profile' so that variable can be development for local machine but it can be changed to devaws when I am building using npm run build:dev?
I use cross-env to set the NODE_ENV in my npm scripts: https://www.npmjs.com/package/cross-env