javascript - React + webpack: 'process.env' is undefined -


i'm trying run hot dev server on our site webpack; site uses reactjs, has code in it:

if (\"production\" !== process.env.node_env) // etc 

when not running hot-swap it's fine, hot-swap, gets run, resulting in error:

typeerror: process.env undefined 

the code looks this:

error on line

the project modelled after https://github.com/webpack/react-starter does work; question is; error have made in config file and/or how go looking error when 'production' compilation works fine?

i've posted gist of webpack config file.

in webpack config, there 2 options can affect process.env:

looking @ code, looks process.env might undefined when both options.prerender , options.minimize false.

you fix using environment defines process.env (ex: node), or using defineplugin assign default value variable yourself.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -