Open valentinvoilean opened 6 years ago
This is my webpack configuration:
rules: [ { test: /\.jsx?$/, exclude: [/node_modules/], loader: ['babel-loader', 'webpack-conditional-loader'] } ], plugins: [ new webpack.EnvironmentPlugin({ NODE_ENV: 'production', BROWSER: true }), ]
Then, in my file I use this:
// #if process.env.NODE_ENV !== 'production' import moment from 'moment'; // #endif
The moment library is still imported.
It works only if I do:
// #if process.env.NODE_ENV === 'anything_other_value' import moment from 'moment'; // #endif
This means, the process.env.NODE_ENV is undefined.
process.env.NODE_ENV
undefined
I'm using: "webpack": "^3.9.1", "webpack-conditional-loader": "^1.0.11",
Just define NODE_ENV as environment variable before call webpack
This is my webpack configuration:
Then, in my file I use this:
The moment library is still imported.
It works only if I do:
This means, the
process.env.NODE_ENV
isundefined
.I'm using: "webpack": "^3.9.1", "webpack-conditional-loader": "^1.0.11",