ShuiRuTian / time-analytics-webpack-plugin

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

Support Multiple Configs [FEATURE] #6

Open LorenDorez opened 1 year ago

LorenDorez commented 1 year ago

Is your feature request related to a problem? Please describe. We leverage webpack to build multiple configs (ie Client and Server versions). I wanted to use this plugin to measure build times but can only do 1 config at a time which isnt ideal.

Describe the solution you'd like SMP add this feature a while agao and since this seems to be the only active plugin to help measure performance i would like to see this added here as well.

ShuiRuTian commented 1 year ago

Hi @LorenDorez, thanks for the request, which is pretty good. And if it's possible, could you please create a minimal repo to reproduce this issue? It's not required, just want to make sure the fix would fit your situation.

LorenDorez commented 1 year ago

Hi @ShuiRuTian ,

If i have time this weekend ill try to create one but basically any config work just duplicate it. We use the function syntax to gain access to the env variables

A quick mockup would be something like this

module.exports = (env, argv)  => {
     const config1 = {
        name: 'myconfig1',
        output: {
          filename: './dist-amd.js',
        },
        entry: './app.js',
        mode: 'production',
      };

     const config2 = {
        name: 'myconfig2',
        output: {
          filename: './dist-commonjs.js',
        },
        entry: './app2.js',
        mode: 'production',
      };

     return [config1, config2]
};

You can find about more options here as it would be nice to support all possible options webpack uses https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations

ShuiRuTian commented 1 year ago

@LorenDorez Sorry for asking, how des SMP support it?

Does it wrap the function or the two configurations?


Auh, I got it, never mind :)

LorenDorez commented 1 year ago

See here... https://github.com/stephencookdev/speed-measure-webpack-plugin/issues/37#issuecomment-382641337

ShuiRuTian commented 1 year ago

Thanks! I was too busy last week. I made some change, and it starts to work, but it seems there are some multi-thread issues and it fails sometimes... Hope I could fix it in this weekend...