Whenever I run my Vue application, the console output indicates:
The running environment is development mode.
Make sure to switch to production mode for deployment.
For more tips, visit https://vuejs.org/guide/deployment.html
Now, I am looking to verify if Vue is in development mode directly from within my templates using:
console.log("The mode is " + process.env.NODE_ENV)
However, it only displays undefined
.
Is there an alternative method to determine NODE_ENV in Vue?
In my webpack configuration, this section exists:
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
Additionally, could be relevant that I utilize TypeScript, and included this type declaration:
declare var process: {
env: {
NODE_ENV: string
}
}