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

Doesn't work #5

Open
valentinvoilean opened this issue Dec 3, 2017 · 1 comment
Open

Doesn't work #5

valentinvoilean opened this issue Dec 3, 2017 · 1 comment

Comments

@valentinvoilean
Copy link

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.

I'm using:
"webpack": "^3.9.1",
"webpack-conditional-loader": "^1.0.11",

@statefull
Copy link

Just define NODE_ENV as environment variable before call 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

2 participants