Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

webpack

vue.js

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)?

like image 949
Adrian Krebs Avatar asked Jul 23 '18 15:07

Adrian Krebs


People also ask

How do I turn off source maps in production?

Source map generation is controlled through Webpack configuration, more specifically in the devtool option. In a nutshell, what we want to do is modify Gatsby's Webpack configuration when running the build script in order to disable source maps if the environment is production.

Should source maps be used in production?

Most JavaScript and CSS sources are usually minified and source maps serve as a memory map to the compressed files. It's generally a good practice to minify and combine your assets (Javascript & CSS) when deploying to production.

How do I hide source maps in Chrome?

Open Developer Tools, go to "Settings" for Developer Tools, then uncheck Enable JavaScript Sourcemaps under the "Sources" settings.

Is Vue maintained by Open Source?

js (commonly referred to as Vue; pronounced "view") is an open-source model–view–viewmodel front end JavaScript framework for building user interfaces and single-page applications. It was created by Evan You, and is maintained by him and the rest of the active core team members.


1 Answers

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 }; 
like image 164
yuriy636 Avatar answered Sep 21 '22 08:09

yuriy636