How can I disable source maps in production for a vue.js app?

Webpackvue.js

Webpack Problem Overview


My app is created with the vue cli. I can't find any option to disable source maps in production. The npm build step in my package.json looks like this:

"build": "vue-cli-service build",

In angular, i can just add --prod to my build step to make it work. Is there any such option for vue.js? Or do I have to change the webpack config (which is hidden by the cli)?

Webpack Solutions


Solution 1 - Webpack

You make changes to the internal webpack config with the vue.config.js file at the project root (you may need to create it manually).

There is a productionSourceMap option so you can disable source maps when building for production:

module.exports = {
  productionSourceMap: false
};

Solution 2 - Webpack

like @yuriy636 's answer, if you want only for production :

module.exports = {
  productionSourceMap: process.env.NODE_ENV != 'production'
};

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdrian KrebsView Question on Stackoverflow
Solution 1 - Webpackyuriy636View Answer on Stackoverflow
Solution 2 - WebpacksolmansView Answer on Stackoverflow