process.env.NODE_ENV is undefined, caused 'isDevMode' useless
linker-junhao opened this issue · comments
hi, @mubaidr , thanks for your work, I am using it for days, it works fine.
and I found that process.env.NODE_ENV is undefined when I use npm run []
command, and I solved it. maybe you can fix it if it happend at your enviroment too.
hree is my enviroment:
npm -v
6.13.4
node -v
v13.6.0
webpack -v
4.41.6
I dont sure is here anybody else encounter this.
solution: according to webpack.js.org/api/cli/#environment-options, export your webpack config as a function will solve it.
like this:
function exportCfgFunction (env, argv) {
const isDevMode = env.NODE_ENV === 'development'
const config = {
devtool: isDevMode ? 'eval-source-map' : false,
context: path.resolve(__dirname, './src'),
entry: {
},
output: {
}
}
return config
}
module.exports = exportCfgFunction
Cool. @linkerGitHub please create a pull request?
Oh, another enviroment information of mine
operation system: macos 10.15.3 catalina
Thanks for the pull request! #391 (comment)