How check if Vue is in development mode?
If you started with vue-cli (default webpack) then this should work:
connection: process.env.NODE_ENV === 'development' ? 'ws://localhost:5000' : 'wss://myawsomeproject.org'
Webpack is used for almost all of my Vue projects, so I check to see if webpackHotUpdate
is present.
if (webpackHotUpdate) { console.log('In Dev Mode'); }
It's present in the window
object if the webpack dev server is running.
I know this is an old question but it may be helpful to new VueJS users to know this solution that I found in the current version of Vue (3.11):
When running in dev mode the property Vue.config.devtools
is true
, in production mode it is false
!