Bhagya Swamy
Bhagya Swamy

Reputation: 95

I need to disable Vue.js devtools for production mode but it should be enabled for development mode

I don’t want my users to inspect the app using devtools so I would like to disable it in the production mode. But I need it in local/development mode. I have tried the below but it is not working.

I have created .env and .env.production files with a variable VUE_APP_ROOT_API

.env file

VUE_APP_ROOT_API=http://localhost

.env.production

VUE_APP_ROOT_API=https://prod.com

in webpack configuration, I have added below

devtool: process.env.VUE_APP_ROOT_API === ‘PROD’ ? ‘source-map’ : ‘’

Please help me.

Upvotes: 0

Views: 3194

Answers (2)

iacobalin
iacobalin

Reputation: 598

If you have used vue-cli to generate your vue project then you do not have to do anything but just run the build commands:

npm run build

or

yarn build

It will have production mode enabled by default and the vue dev tools disabled. Docs here: https://cli.vuejs.org/guide/cli-service.html#vue-cli-service-build

Otherwise just bundle your application in production mode as described here: https://v2.vuejs.org/v2/guide/deployment.html#With-Build-Tools

In both cases dev tools should be disabled

Upvotes: 0

tauzN
tauzN

Reputation: 6951

if (process.env.NODE_ENV === 'development') {
  devtools.connect(/* host, port */)
}

Upvotes: 1

Related Questions