stephencookdev / speed-measure-webpack-plugin

⏱ See how fast (or not) your plugins and loaders are, so you can optimise your builds
MIT License
2.4k stars 80 forks source link

how to use this plugin in vue-cli3 #90

Open jizai94 opened 4 years ago

AllenChinese commented 4 years ago

you can do it like this:

const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
const smp = new SpeedMeasurePlugin()

module.exports = {
    ...,
    configureWebpack: smp.wrap({
        output: {
        ...
        },
        plugins: [
           ...
        ]
    })
}
pengfeir commented 4 years ago

@AllenChinese I follow your configuration but it does not take effect

gottayan commented 4 years ago

@AllenChinese I follow your configuration but it does not take effect

yeah same to me it does not take effect.

joyerli commented 4 years ago

I created a new vue-cli plug-in. The main content of the plug-in is:

const origin = api.service.resolveWebpackConfig.bind(api.service);
  api.service.resolveWebpackConfig = (...params) => {
    const config = origin(...params);
    const smp = new SpeedMeasurePlugin();
    return smp.wrap(config);
  };

By resetting 'api.service.resolvewebpackconfig', SMP wraps all webpack configurations