webpack-conditional-loader
webpack-conditional-loader copied to clipboard
DefinePlugin - not seeing variables
I am using define plugin to set some environment variables, The loader doesn't seem to be picking them up?
Same here~
You can only use node.js environment process.env.YOUR_VARIABLE
// #if process.env.YOUR_VARIABLE !== 'BUILD'
// DO YOUR BUSINESS HERE
// #endif
By design in webpack, loaders run before plugins. So the variables defined by DefinePlugin are not "seen" by
webpack-conditional-loader because they are not text-replaced yet
@deepakanand any idea how to resolve this issue?
@deepakanand any idea how to resolve this issue?
Just specify this variable in the Node.js environment.
Instead of
new webpack.DefinePlugin({
YOUR_VARIABLE: JSON.stringify(true),
});
Use
$ YOUR_VARIABLE=true webpack