Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefinePlugin - not seeing variables #14

Open
undeadcellist opened this issue Mar 14, 2019 · 4 comments
Open

DefinePlugin - not seeing variables #14

undeadcellist opened this issue Mar 14, 2019 · 4 comments

Comments

@undeadcellist
Copy link

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

@dzoneo
Copy link

dzoneo commented Apr 25, 2019

Same here~

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

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

// DO YOUR BUSINESS HERE

// #endif

@deepakanand
Copy link

deepakanand commented Oct 19, 2020

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

@medin-n
Copy link

medin-n commented Jan 27, 2021

@deepakanand any idea how to resolve this issue?

@banyudu
Copy link

banyudu commented Nov 29, 2021

@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 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants