speed-measure-webpack-plugin icon indicating copy to clipboard operation
speed-measure-webpack-plugin copied to clipboard

How to use with vue project create by vue-cli 3.0

Open chs97 opened this issue 5 years ago • 19 comments

How to use with vue project create by vue-cli 3.0

chs97 avatar Nov 17 '18 10:11 chs97

Same issue, I have setup like so:

const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");

const smp = new SpeedMeasurePlugin({
  outputTarget: './smp.dat',
});
var StylelintPlugin = require('stylelint-webpack-plugin');

module.exports = {
  configureWebpack: smp.wrap({
    entry: './src/entry.ts',
    plugins: [
      new StylelintPlugin({
        files: ['src/**/*.less', 'src/**/*.css'],
        emitErrors: false
      })
    ]
  }),
  chainWebpack: (config) => {
    config.devtool('source-map');
  },
  devServer: {
    open: process.platform === 'darwin',
    host: '0.0.0.0',
    port: 8080,
    https: false,
    hotOnly: false,
  },
  parallel: true,
};

However I get output like this on incremental builds:

 SMP  ⏱  
General output time took 29.69 secs

 SMP  ⏱  Plugins
Object took 2.98 secs

 SMP  ⏱  Loaders
D:\Development\alloy-web\node_modules\cache-loader\dist\cjs.js, and 
D:\Development\alloy-web\node_modules\vue-loader\lib\index.js took 0.685 secs
  module count = 1
D:\Development\alloy-web\node_modules\css-loader\index.js, and 
D:\Development\alloy-web\node_modules\vue-loader\lib\loaders\stylePostLoader.js, and 
D:\Development\alloy-web\node_modules\postcss-loader\src\index.js, and 
D:\Development\alloy-web\node_modules\cache-loader\dist\cjs.js, and 
D:\Development\alloy-web\node_modules\vue-loader\lib\index.js took 0.07 secs
  module count = 1
D:\Development\alloy-web\node_modules\cache-loader\dist\cjs.js, and 
D:\Development\alloy-web\node_modules\vue-loader\lib\loaders\templateLoader.js, and 
D:\Development\alloy-web\node_modules\cache-loader\dist\cjs.js, and 
D:\Development\alloy-web\node_modules\vue-loader\lib\index.js took 0.042 secs
  module count = 1
D:\Development\alloy-web\node_modules\cache-loader\dist\cjs.js, and 
D:\Development\alloy-web\node_modules\ts-loader\index.js, and 
D:\Development\alloy-web\node_modules\cache-loader\dist\cjs.js, and 
D:\Development\alloy-web\node_modules\vue-loader\lib\index.js took 0.039 secs
  module count = 1

Which gives no information about what happens in General output time

cmcnicholas avatar Dec 12 '18 19:12 cmcnicholas

@cmcnicholas is that output from running on Windows?

stephencookdev avatar Jan 19 '19 17:01 stephencookdev

@cmcnicholas is that output from running on Windows?

yep

cmcnicholas avatar Jan 21 '19 10:01 cmcnicholas

@cmcnicholas same problem, has the problem been solved?

xubaoshi avatar May 22 '19 07:05 xubaoshi

Any luck yet? really need to see the build times :)

vpiskunov avatar Sep 11 '19 11:09 vpiskunov

Alright, I made it work: in your vue.config.js, do the following:

module.exports = {
  configureWebpack: (config) => {
    smp.wrap(config);
  },
};

If you have anything in your configureWebpack, ensure configureWebpack is a function, not an object/array.

Then add smp.wrap(config) to the last line inside your configureWebpack

Producing following output for me:

 SMP  ⏱  
General output time took 23.49 secs

 SMP  ⏱  Plugins
WatchStateLoggerPlugin took 0.056 secs
Object took 0.044 secs
VueLoaderPlugin took 0.026 secs
HotModuleReplacementPlugin took 0.024 secs
GenerateBundleStarterPlugin took 0.001 secs
DefinePlugin took 0 secs
NativeScriptWorkerPlugin took 0 secs

 SMP  ⏱  Loaders
babel-loader took 12.49 secs
  module count = 205
nativescript-dev-webpack, and 
nativescript-dev-webpack, and 
string-replace-loader, and 
css-loader, and 
vue-loader, and 
postcss-loader, and 
sass-loader, and 
vue-loader, and 
string-replace-loader took 8.067 secs
  module count = 4
nativescript-dev-webpack, and 
babel-loader, and 
eslint-loader took 2.086 secs
  module count = 1
nativescript-dev-webpack, and 
nativescript-dev-webpack, and 
string-replace-loader, and 
css-loader, and 
vue-loader, and 
postcss-loader, and 
vue-loader, and 
string-replace-loader took 0.844 secs
  module count = 1
vue-loader, and 
string-replace-loader, and 
eslint-loader took 0.685 secs
  module count = 11
vue-loader, and 
vue-loader, and 
string-replace-loader took 0.31 secs
  module count = 6
modules with no loaders took 0.219 secs
  module count = 2
babel-loader, and 
eslint-loader took 0.211 secs
  module count = 2
babel-loader, and 
vue-loader, and 
string-replace-loader took 0.088 secs
  module count = 4
vue-loader, and 
nativescript-dev-webpack, and 
nativescript-dev-webpack, and 
string-replace-loader, and 
css-loader, and 
postcss-loader, and 
sass-loader, and 
vue-loader, and 
string-replace-loader, and 
eslint-loader took 0.004 secs
  module count = 4
vue-loader, and 
babel-loader, and 
vue-loader, and 
string-replace-loader, and 
eslint-loader, and 
eslint-loader took 0.003 secs
  module count = 4
vue-loader, and 
nativescript-dev-webpack, and 
nativescript-dev-webpack, and 
string-replace-loader, and 
css-loader, and 
postcss-loader, and 
vue-loader, and 
string-replace-loader, and 
eslint-loader took 0.001 secs
  module count = 1

vpiskunov avatar Sep 11 '19 13:09 vpiskunov

@stephencookdev Maybe we can add this to Readme.md or to examples dir? Happy to contribute

vpiskunov avatar Sep 11 '19 13:09 vpiskunov

Nice one @vpiskunov - yeah a entry in the examples dir would be amazing. Happy to accept PRs for that :slightly_smiling_face:

stephencookdev avatar Sep 12 '19 08:09 stephencookdev

@stephencookdev actually my solution above worked but only during npm run ios (it's a vue+nativescript project), but failed on web-build running into #63

Seems like this could be related: https://github.com/jantimon/html-webpack-plugin/issues/875 https://github.com/GoogleChromeLabs/preload-webpack-plugin/issues/86

Let me know what you think.

vpiskunov avatar Sep 13 '19 13:09 vpiskunov

I got my build working by using configureWebpack: smp.wrap({ plugins: [] }),

(I don't have any custom plugins)

but not sure show to interpret the results


C:\Brandollo\Code\brdl-website\node_modules\mini-css-extract-plugin\dist\loader.js, and
C:\Brandollo\Code\brdl-website\node_modules\css-loader\index.js, and
C:\Brandollo\Code\brdl-website\node_modules\vue-loader\lib\loaders\stylePostLoader.js, and
C:\Brandollo\Code\brdl-website\node_modules\postcss-loader\src\index.js, and
C:\Brandollo\Code\brdl-website\node_modules\sass-loader\lib\loader.js, and
C:\Brandollo\Code\brdl-website\node_modules\cache-loader\dist\cjs.js, and
C:\Brandollo\Code\brdl-website\node_modules\vue-loader\lib\index.js took 12.44 secs
  module count = 104
C:\Brandollo\Code\brdl-website\node_modules\css-loader\index.js, and
C:\Brandollo\Code\brdl-website\node_modules\vue-loader\lib\loaders\stylePostLoader.js, and
C:\Brandollo\Code\brdl-website\node_modules\postcss-loader\src\index.js, and
C:\Brandollo\Code\brdl-website\node_modules\sass-loader\lib\loader.js, and
C:\Brandollo\Code\brdl-website\node_modules\cache-loader\dist\cjs.js, and
C:\Brandollo\Code\brdl-website\node_modules\vue-loader\lib\index.js took 12.26 secs
  module count = 104

mmusket avatar Oct 23 '19 01:10 mmusket

@vpiskunov I followed your configuration but gave an error image

pengfeir avatar Dec 25 '19 03:12 pengfeir

Same for me, getting the Cannot read property 'tap' of undefined error when trying using smp.wrap(config); in configureWebpack function.

"@vue/cli-service": "^4.1.2",
"speed-measure-webpack-plugin": "^1.3.1",

Defining configureWebpack as an object, not as function does not cause the failure, though.

klesun avatar Jan 28 '20 10:01 klesun

I need apply it with vux loader but it doesn't work.

if I try this like you it is ok.

configureWebpack: smp.wrap({ plugins: [ new BundleAnalyzerPlugin ] })

but it does not work like this.at the same time the vim has no errors.

configureWebpack: config => { const mergeConfig = require('vux-loader').merge(config, { plugins: [ { name: 'vux-ui' }, { name: 'duplicate-style' }, { name: 'less-theme', path: 'src/theme.less' } ] }) smp.wrap(mergeConfig) }

gottayan avatar Mar 24 '20 10:03 gottayan

...has anyone figured out the fix for Cannot read property 'tap' of undefined? I'd love to use this lib to get my build time down.

destroytoday avatar Jun 14 '20 21:06 destroytoday

If you have this error : TypeError: Cannot read property 'tap' of undefined.

VueJS doc (https://cli.vuejs.org/config/#configurewebpack) says that we can pass Object or Function as parameter of configureWebpack attribute.

Try the following code on vue.config.js :

const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const smp = new SpeedMeasurePlugin();
module.exports = {
  configureWebpack: smp.wrap({})
}

afelipez avatar Aug 03 '20 11:08 afelipez

If you use vue-cli3, use chainWebpack in vue.config.js

const SpeedMeasurePlugin = require("speed-measure-webpack-plugin")

module.exports = {
// ...
  chainWebpack: config => {
    // ...
  config
    .plugin('speed-measure-webpack-plugin')
    .use(SpeedMeasurePlugin)
    .end()
  }
}

yangger6 avatar Dec 23 '20 06:12 yangger6

If you use vue-cli3, use chainWebpack in vue.config.js

const SpeedMeasurePlugin = require("speed-measure-webpack-plugin")

module.exports = {
// ...
  chainWebpack: config => {
    // ...
  config
    .plugin('speed-measure-webpack-plugin')
    .use(SpeedMeasurePlugin)
    .end()
  }
}

I configure like you, but I can't measure the time of plugins image

yangtianfu01 avatar Mar 23 '21 00:03 yangtianfu01

If you use vue-cli3, use chainWebpack in vue.config.js

const SpeedMeasurePlugin = require("speed-measure-webpack-plugin")

module.exports = {
// ...
  chainWebpack: config => {
    // ...
  config
    .plugin('speed-measure-webpack-plugin')
    .use(SpeedMeasurePlugin)
    .end()
  }
}

I tried configuring my chainWebpack like this but it doesn't measure a bunch of plugins. This is the output I got.

SMP ⏱
General output time took 32 mins, 43.8 secs

SMP ⏱ Loaders cache-loader, and thread-loader, and babel-loader took 2 mins, 37.65 secs module count = 435 mini-css-extract-plugin, and css-loader, and postcss-loader, and sass-loader took 2 mins, 4.49 secs module count = 98 css-loader, and postcss-loader, and sass-loader took 2 mins, 4.43 secs module count = 98 modules with no loaders took 2 mins, 0.363 secs module count = 572 vue-loader, and mini-css-extract-plugin, and css-loader, and postcss-loader, and sass-loader, and cache-loader, and vue-loader took 1 min, 43.13 secs module count = 148 css-loader, and vue-loader, and postcss-loader, and sass-loader, and cache-loader, and vue-loader took 1 min, 42.75 secs module count = 74 vue-loader, and cache-loader, and

wheelebin avatar Nov 30 '21 18:11 wheelebin

If you use vue-cli3, use chainWebpack in vue.config.js

const SpeedMeasurePlugin = require("speed-measure-webpack-plugin")

module.exports = {
// ...
  chainWebpack: config => {
    // ...
  config
    .plugin('speed-measure-webpack-plugin')
    .use(SpeedMeasurePlugin)
    .end()
  }
}

I tried configuring my chainWebpack like this but it doesn't measure a bunch of plugins. This is the output I got.

SMP ⏱ General output time took 32 mins, 43.8 secs

SMP ⏱ Loaders cache-loader, and thread-loader, and babel-loader took 2 mins, 37.65 secs module count = 435 mini-css-extract-plugin, and css-loader, and postcss-loader, and sass-loader took 2 mins, 4.49 secs module count = 98 css-loader, and postcss-loader, and sass-loader took 2 mins, 4.43 secs module count = 98 modules with no loaders took 2 mins, 0.363 secs module count = 572 vue-loader, and mini-css-extract-plugin, and css-loader, and postcss-loader, and sass-loader, and cache-loader, and vue-loader took 1 min, 43.13 secs module count = 148 css-loader, and vue-loader, and postcss-loader, and sass-loader, and cache-loader, and vue-loader took 1 min, 42.75 secs module count = 74 vue-loader, and cache-loader, and

For anyone facing the same problem, I found a comment on an issue from vue-cli's repo with a workaround and managed to get it working by following his second option.

https://github.com/vuejs/vue-cli/issues/6091#issuecomment-738536334

wheelebin avatar Nov 30 '21 21:11 wheelebin