How can I disable source maps in production for a vue.js app?
Webpackvue.jsWebpack 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'
};