Reputation: 1543
There is process.env.NODE_ENV==='development'
but that's defined on server side which runs webpack or its dev-server. I need to determine it from the bundled code which runs in a browser.
Upvotes: 2
Views: 632
Reputation: 7287
You can use webpack.DefinePlugin
in the building process to define a global variable like this:
//
const mode = "production"
module.exports = {
mode: mode,
// ...
plugins: [
new webpack.DefinePlugin({
__mode__: JSON.stringify(mode)
})
]
}
Then you can access __mode__
.
Upvotes: 2