webpack-conditional-loader icon indicating copy to clipboard operation
webpack-conditional-loader copied to clipboard

DefinePlugin - not seeing variables

Open undeadcellist opened this issue 6 years ago • 4 comments

I am using define plugin to set some environment variables, The loader doesn't seem to be picking them up?

undeadcellist avatar Mar 14 '19 12:03 undeadcellist

Same here~

You can only use node.js environment process.env.YOUR_VARIABLE

// #if process.env.YOUR_VARIABLE !== 'BUILD'

// DO YOUR BUSINESS HERE

// #endif

dzoneo avatar Apr 25 '19 03:04 dzoneo

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 avatar Oct 19 '20 02:10 deepakanand

@deepakanand any idea how to resolve this issue?

medin-n avatar Jan 27 '21 11:01 medin-n

@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 

banyudu avatar Nov 29 '21 08:11 banyudu