ShuiRuTian / time-analytics-webpack-plugin

Analytics the time cost of loaders and plugins in webpack, to optimise accordingly.
31 stars 0 forks source link

How to use it in vue-cli3? #9

Open BuugMakerr opened 10 months ago

BuugMakerr commented 10 months ago

Thank you for providing this plugin. If I want to configure this plugin in my Vue2 project based on Vue cli3, that is, in vue.config.js, what should I do, especially when both configureWebpack and chainWebpack exist

BuugMakerr commented 10 months ago

(我zz了,好像可以说中文O.O)

BuugMakerr commented 10 months ago

我尝试了以下几种方法,但是都没有输出时间信息: 1. 在vue.config.js中: const { TimeAnalyticsPlugin } = require("time-analytics-webpack-plugin"); module.exports = TimeAnalyticsPlugin.wrap({...}); 2. 直接修改build/index.js源码:

const { TimeAnalyticsPlugin } = require('time-analytics-webpack-plugin');
  const webpackConig = TimeAnalyticsPlugin.wrap(webpackConfig);

  return new Promise((resolve, reject) => {
    webpack(webpackConfig, (err, stats) => {
      ...
    })
   })

这两种方法都不生效

ShuiRuTian commented 10 months ago

抱歉,我从来没用过Vue。。 这个plugin的工作原理是接管plugin和loader,在它们执行前后记录时间。 为此,我们需要包裹本来需要使用的webpack config,从而允许我们做些注入和修改

在你提供的例子里看上去确实包裹了。。 如果可能的话,能提供一个能重现这个问题的repo吗