Vue.js-fix vue-cli automatically compress code after packaging

Source: Internet
Author: User

When we finished the project with Vue Scaffolding, the NPM run build was packaged,

There is no view of the source code, all compressed good. But I don't want to let it compress, what should I do?

Puzzled for a few days, looked up all kinds of information. Finally, finally ...

Come on, dry:

First, we have to understand a little bit of webpack knowledge.

Webpack in the compression JS plug-in called Uglifyjs-webpack-plugin,

The plugin for compressing CSS is called Optimize-css-assets-webpack-plugin

Then we found the/build/webpack.prod.conf.js file,

Then you will find:

Const Optimizecssplugin = require (' optimize-css-assets-webpack-plugin '= require (' Uglifyjs-webpack-plugin ') )

Then we can search the page for Optimizecssplugin and Uglifyjsplugin, where the two key words are located.

The configuration is as follows:

 //  CSS compression code, comment out the code below  new   Optimizecssplugin ({cssprocessoroptions: Config.build.productionSourceMap ? {safe: true , Map: {inline: false  }}: {safe:  true  } }),
   // compress the JS code and comment out    the code below New Uglifyjsplugin ({      uglifyoptions: {        compress: {          false        }      },      SourceMap:config.build.productionSourceMap,      true    }),

Just comment out the above code, NPM run build and you'll find out, OU.

Then there's the HTML,

The configuration is as follows:

 new   Htmlwebpackplugin ({filename: Process.env.NODE_ENV  = = = ' testing '? ' index.html ' : Config.build.index, Template:  ' index.html ' 

Here we change the minify above into Minify:false.

Yes, I can.

Vue.js-fix vue-cli automatically compress code after packaging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.