When I run my Vue app, the console shows:
You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html
So now I want to check if Vue is in development from inside my templates by using:
console.log("mode is " + process.env.NODE_ENV)
But that only logs undefined
Is there a different way to find the NODE_ENV in Vue?
My webpack config has this part:
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 }) ]) }
Perhaps relevant: I use typescript, so I included this type declaration:
declare var process: { env: { NODE_ENV: string } }
VueJS is an open source progressive JavaScript framework used to develop interactive web interfaces. It is one of the famous frameworks used to simplify web development. VueJS focusses on the view layer. It can be easily integrated into big projects for front-end development without any issues.
js is an open-source model-view-view model (MVVM) JavaScript framework.
Can I use Vue 3 or should I still use Vue 2 for a new project? You can start your new production projects with Vue 3 - the core and subprojects are ready to use. Keep in mind that the ecosystem is still evolving, so some open-source components may not yet available in Vue 3 versions.
If you started with vue-cli (default webpack) then this should work:
connection: process.env.NODE_ENV === 'development' ? 'ws://localhost:5000' : 'wss://myawsomeproject.org'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With