vue. config. Implementation of configuring webpack in JS to improve code compilation speed

Time:2022-5-5

Refer to relevant documents:

One line of code can make the project start more than 70% faster
https://mp.weixin.qq.com/s/eS…

The following two methods can improve the compilation speed
The speed of starting local projects is generally slow for the first time, and the speed increases a lot after the second time

Install the plug-in in the development environment and only optimize the compilation speed of the development environment
NPM I hard source webpack plugin – D / / increase compilation speed
NPM I speed measure webpack plugin – D / / displays the compilation time

In Vue config. JS
const HardSourceWebpackPlugin = require(‘hard-source-webpack-plugin’);
const SpeedMeasurePlugin = require(‘speed-measure-webpack-plugin’);

1. Chain writing

chainWebpack: (config) => {
    config. plugin('xcCache'). use(HardSourceWebpackPlugin); //  Custom plug-in name
    config.plugin('xcTime').use(SpeedMeasurePlugin);
},

2. Common writing

configureWebpack: {
    plugins: [
        new HardSourceWebpackPlugin(),
        new SpeedMeasurePlugin()
    ]
},

Recommended Today

Modify user information changeinfo

When judging the persistence layer: Problem: there is such a problem when modifying user information. For example: the user’s email is not required. It was not empty originally. At this time, the user deletes the mailbox information and submits it. At this time, if it is not empty to judge whether it needs to be […]