Coder Social home page Coder Social logo

stephencookdev / speed-measure-webpack-plugin Goto Github PK

View Code? Open in Web Editor NEW
2.4K 14.0 80.0 1.98 MB

⏱ See how fast (or not) your plugins and loaders are, so you can optimise your builds

License: MIT License

JavaScript 99.95% CSS 0.05%
webpack speed stats plugin measure timer

speed-measure-webpack-plugin's Introduction

Speed Measure Plugin
(for webpack)


The first step to optimising your webpack build speed, is to know where to focus your attention.

This plugin measures your webpack build speed, giving an output like this:

Preview of Speed Measure Plugin's output

Install

npm install --save-dev speed-measure-webpack-plugin

or

yarn add -D speed-measure-webpack-plugin

Requirements

SMP requires at least Node v6. But otherwise, accepts all webpack versions (1, 2, 3, and 4).

Usage

Change your webpack config from

const webpackConfig = {
  plugins: [new MyPlugin(), new MyOtherPlugin()],
};

to

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

const smp = new SpeedMeasurePlugin();

const webpackConfig = smp.wrap({
  plugins: [new MyPlugin(), new MyOtherPlugin()],
});

and you're done! SMP will now be printing timing output to the console by default.

Check out the examples folder for some more examples.

Options

Pass these into the constructor, as an object:

const smp = new SpeedMeasurePlugin(options);

options.disable

Type: Boolean
Default: false

If truthy, this plugin does nothing at all.

{ disable: !process.env.MEASURE } allows opt-in measurements with MEASURE=true npm run build.

options.outputFormat

Type: String|Function
Default: "human"

Determines in what format this plugin prints its measurements

  • "json" - produces a JSON blob
  • "human" - produces a human readable output
  • "humanVerbose" - produces a more verbose version of the human readable output
  • If a function, it will call the function with the JSON blob, and output the response

options.outputTarget

Type: String|Function
Default: console.log

  • If a string, it specifies the path to a file to output to.
  • If a function, it will call the function with the output as the first parameter

options.pluginNames

Type: Object
Default: {}

By default, SMP derives plugin names through plugin.constructor.name. For some plugins this doesn't work (or you may want to override this default). This option takes an object of pluginName: PluginConstructor, e.g.

const uglify = new UglifyJSPlugin();
const smp = new SpeedMeasurePlugin({
  pluginNames: {
    customUglifyName: uglify,
  },
});

const webpackConfig = smp.wrap({
  plugins: [uglify],
});

options.loaderTopFiles

Type: Number
Default: 0

You can configure SMP to include the files that take the most time per loader, when using outputFormat: 'humanVerbose'. E.g., to show the top 10 files per loader:

const smp = new SpeedMeasurePlugin({
  outputFormat: "humanVerbose",
  loaderTopFiles: 10,
});

options.compareLoadersBuild

Type: Object
Default: {}

This option gives you a comparison over time of the module count and time spent, per loader. This option provides more data when outputFormat: "humanVerbose".

Given a required filePath to store the build information, this option allows you to compare differences to your codebase over time. E.g.

const smp = new SpeedMeasurePlugin({
  compareLoadersBuild: {
    filePath: "./buildInfo.json",
  },
});

options.granularLoaderData (experimental)

Type: Boolean
Default: false

By default, SMP measures loaders in groups. If truthy, this plugin will give per-loader timing information.

This flag is experimental. Some loaders will have inaccurate results:

  • loaders using separate processes (e.g. thread-loader)
  • loaders emitting file output (e.g. file-loader)

We will find solutions to these issues before removing the (experimental) flag on this option.

FAQ

What does general output time mean?

This tends to be down to webpack reading in from the file-system, but in general it's anything outside of what SMP can actually measure.

What does modules without loaders mean?

It means vanilla JS files, which webpack can handle out of the box.

Contributing

Contributors are welcome! 😊

Please check out the CONTRIBUTING.md.

Migrating

SMP follows semver. If upgrading a major version, you can consult the migration guide.

License

MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Stephen Cook

💻 📖 📝 🎨 💬 👀

scarletsky

💻

牛さん

💻 🐛

Thomas Bentkowski

📖

Alan Agius

💻 🐛

Ximing

💻 🐛

Tan Li Hau

💻 🐛 ⚠️

Björn Brauer

💻 🐛

Suraj Patel

💻

Jm

💻 🐛 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

speed-measure-webpack-plugin's People

Contributors

hanzooo avatar ndyag avatar scarletsky avatar stephencookdev avatar tanhauhau avatar the-only-matrix avatar thomasharper avatar wayou avatar zaubernerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

speed-measure-webpack-plugin's Issues

Incompatibility with hard-source-webpack-plugin…

Hey there!

This plugin is awesome, unfortunately it seems to break another fav plugin of mine, hard-source-webpack-plugin, that is currently the most effective caching layer Webpack has (including v4). First run will work fine, later runs, once a cache exist, will break when this plugin exists.

This may be due to its not properly using v4’s plugin API yet? No idea. Still, this prevents me from using it everywhere right now. It'd be super sweet if you could coordinate with HS' author to figure this out.

Thanks a ton!

Cannot read property 'tap' of undefined

i use create-react-app , but i upgrade webpack4 .19.0.

it throw error.

[email protected] start /Users/mac/Desktop/study/webpack-study/demo1
node scripts/start.js

Cannot read property 'tap' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node scripts/start.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2018-09-22T08_11_44_724Z-debug.log

/Users/mac/.npm/_logs/2018-09-22T08_11_44_724Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 info lifecycle [email protected]
start: [email protected]
7 verbose lifecycle [email protected]start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/mac/Desktop/study/webpack-study/demo1/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle [email protected]start: CWD: /Users/mac/Desktop/study/webpack-study/demo1
10 silly lifecycle [email protected]
start: Args: [ '-c', 'node scripts/start.js' ]
11 silly lifecycle [email protected]start: Returned: code: 1 signal: null
12 info lifecycle [email protected]
start: Failed to exec start script
13 verbose stack Error: [email protected] start: node scripts/start.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/mac/Desktop/study/webpack-study/demo1
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start"
18 verbose node v8.11.3
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: node scripts/start.js
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Include time taken during minimization

In Webpack 4, we specify the minimizer like so:

  optimization: {
    minimizer: [
      new TerserPlugin({
        sourceMap: true,
        parallel: true,
        cache: './.build_cache/terser',
        exclude: /transpiledLibs/,
        terserOptions: {
          warnings: false,
          ie8: false
        }
      })
    ]
  },

Meaning that it is no longer included in the SMP output time. This would be a nice addition to the plugin :)

issue with fork ts plugin

Message:
Error: TypeError: Cannot read property 'tap' of undefined
Stack:
Error: Error: TypeError: Cannot read property 'tap' of undefined
at ForkTsCheckerNotifierWebpackPlugin.apply (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/fork-ts-checker-notifier-webpack-plugin/index.js:65:23)
at WrappedPlugin.apply (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:277:29)
at webpack (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/webpack/lib/webpack.js:47:13)
at Gulp. (/Users/mfrankel/Workspace/amplify-dashboard/webapp/build/gulp/serve.gulp.js:43:22)
at module.exports (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/index.js:134:8)
at runNextSet (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/run-sequence/index.js:86:16)
at Gulp.onTaskEnd (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/run-sequence/index.js:75:5)
at emitOne (events.js:120:20)
at Gulp.emit (events.js:210:7)
at Gulp.Orchestrator._emitTaskDone (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/index.js:264:8)
at /Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/index.js:275:23
at finish (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/lib/runTask.js:21:8)
at /Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/orchestrator/lib/runTask.js:52:4
at f (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/end-of-stream/node_modules/once/once.js:17:25)
at DestroyableTransform.onend (/Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/end-of-stream/index.js:31:18)
at emitNone (events.js:110:20)
at DestroyableTransform.emit (events.js:207:7)
at /Users/mfrankel/Workspace/amplify-dashboard/webapp/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:965:16
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)

package.json

"devDependencies": {
"@types/angular": "^1.6.10",
"@types/angular-animate": "^1.5.6",
"@types/angular-cookies": "^1.4.3",
"@types/angular-mocks": "^1.5.9",
"@types/angular-sanitize": "^1.3.4",
"@types/angular-scroll": "0.0.30",
"@types/angular-storage": "0.0.30",
"@types/highcharts": "4.2.52",
"@types/jasmine": "^2.5.54",
"@types/jquery": "^2.0.41",
"@types/lodash": "^3.10.1",
"@types/mysql": "0.0.31",
"@types/ng-dialog": "^0.6.0",
"@types/ng-file-upload": "^12.2.0",
"@types/node": "^7.0.10",
"@types/papaparse": "^4.1.28",
"@types/q": "^1.0.0",
"@types/selenium-webdriver": "^3.0.0",
"angular2-template-loader": "^0.6.2",
"chalk": "^1.1.3",
"config": "^1.19.0",
"css-loader": "^0.28.11",
"file-loader": "^1.1.11",
"fork-ts-checker-notifier-webpack-plugin": "^0.6.2",
"fork-ts-checker-webpack-plugin": "^0.4.14",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-help": "^1.6.0",
"gulp-iconfont": "^9.0.0",
"gulp-insert": "^0.5.0",
"gulp-protractor": "^4.1.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-sourcemaps": "^1.6.0",
"gulp-template": "^3.0.0",
"gulp-typescript": "^3.1.3",
"gulp-uncache": "^0.4.0-beta1",
"gulp-util": "^3.0.8",
"gulp-webserver": "^0.9.1",
"gulp-zip": "^3.0.2",
"happypack": "^5.0.0",
"hard-source-webpack-plugin": "^0.12.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"http-proxy": "^1.14.0",
"jasmine-reporters": "^2.3.0",
"jasmine-spec-reporter": "^4.2.1",
"jshint": "^2.9.5",
"jshint-stylish": "^2.0.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.1.2",
"karma-junit-reporter": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^3.0.0",
"leonardojs": "^4.0.5",
"less": "^2.7.2",
"less-loader": "^4.1.0",
"lodash.assign": "^3.2.0",
"merge-stream": "^0.1.8",
"mkdirp": "^0.5.1",
"mysql": "^2.10.2",
"node-proxy-table": "0.0.6",
"open-browser-webpack-plugin": "^0.0.5",
"progress-bar-webpack-plugin": "^1.11.0",
"protractor": "^5.4.1",
"protractor-jasmine2-screenshot-reporter": "^0.3.3",
"protractor-retry": "git+https://github.com/MrFrankel/protractor-retry.git",
"protractor-video-reporter": "^0.3.0",
"pug": "^2.0.3",
"pug-loader": "^2.4.0",
"raw-loader": "^0.5.1",
"readable-stream": "^2.3.6",
"request": "^2.69.0",
"request-promise": "^2.0.1",
"require-dir": "^0.3.0",
"run-sequence": "^1.1.1",
"script-loader": "^0.7.2",
"share-loader": "^0.2.2",
"source-map-loader": "^0.2.3",
"speed-measure-webpack-plugin": "^1.2.3",
"style-loader": "^0.21.0",
"svgo": "^1.0.5",
"svgo-loader": "^2.1.0",
"ts-loader": "^5.3.0",
"tslint": "^5.5.0",
"typescript": "2.8.3",
"url-loader": "^1.0.1",
"webpack": "^4.25.0",
"webpack-bundle-analyzer": "^2.3.1",
"webpack-cli": "^3.1.2",
"webpack-dev-middleware": "^3.1.3",
"webpack-dev-server": "^3.1.10",
"webpack-visualizer-plugin": "^0.1.11",
"yargs": "^3.15.0",
"svg-sprite-loader": "^3.8.0",
"jasmine": "^3.1.0",
"jasmine-core": "^3.1.0",
"optimize-css-assets-webpack-plugin": "3.2.0",
"mini-css-extract-plugin": "^0.4.0"
},

help is appreciated, thanks!

TypeError: 'set' on proxy: trap returned falsish for property 'modules' for ModuleConcatenationPlugin

Hello again :)
Here is another issue I encountered when running this plugin using ModuleConcatenationPlugin

Full stacktrace:

/Users/anf/projects/my_app/node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js:181
        compilation.modules = compilation.modules.filter(m => !usedModules.has(m));
                            ^

TypeError: 'set' on proxy: trap returned falsish for property 'modules'
  at Proxy.compilation.plugin (/Users/anf/projects/my_app/node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js:181:25)
  at Compilation.wrappedFunc (/Users/anf/projects/my_app/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:13:24)
  at Compilation.applyPluginsBailResult (/Users/anf/projects/my_app/node_modules/tapable/lib/Tapable.js:129:27)
  at sealPart2 (/Users/anf/projects/my_app/node_modules/webpack/lib/Compilation.js:613:10)
  at Compilation.applyPluginsAsyncSeries (/Users/anf/projects/my_app/node_modules/tapable/lib/Tapable.js:195:46)
  at Compilation.seal (/Users/anf/projects/my_app/node_modules/webpack/lib/Compilation.js:605:8)
  at applyPluginsParallel.err (/Users/anf/projects/my_app/node_modules/webpack/lib/Compiler.js:504:17)
  at /Users/anf/projects/my_app/node_modules/tapable/lib/Tapable.js:289:11
  at _addModuleChain (/Users/anf/projects/my_app/node_modules/webpack/lib/Compilation.js:507:11)
  at processModuleDependencies.err (/Users/anf/projects/my_app/node_modules/webpack/lib/Compilation.js:477:14)
  at process._tickCallback (internal/process/next_tick.js:150:11)

Plugin breaks with webpack serve watch mode + HardSourceWebpackPlugin

Plugin works nicely for initial build, but breaks when some file is changed and webpack/webpack-serve is watching for changes.

This happens only when HardSourceWebpackPlugin is included.

ℹ 「hot」: webpack: Compiling Done
ℹ 「wdm」:    1410 modules
ℹ 「wdm」: Compiled successfully.
ℹ 「hot」: webpack: Bundle Invalidated
ℹ 「wdm」: Compiling...
[hard-source:core] HardSourceWebpackPlugin is using 177 MB of disk space.
✖ 「wdm」: TypeError: Cannot read property 'call' of undefined
    at Object.exports.call (/Users/guns/oooo/node_modules/hard-source-webpack-plugin/lib/util/plugin-compat.js:170:17)
    at Proxy.run (/Users/guns/oooo/node_modules/hard-source-webpack-plugin/lib/SystemArchetype.js:184:20)
    at args (/Users/guns/oooo/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:52:19)
    at _fn7.then._result7 (eval at create (/Users/guns/oooo/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:51:1)

Also if I remove speed-measure-webpack-plugin, everything works fine. let me know if you need more info.

per loader info

Currently we only report info on aggregate loader groups

But we can get per-loader timing info with a bit more work

Webpack 2 misc/compile/end missing

@guptakvgaurav managed to get the following error with his webpack set-up:

Could not find a matching event to end misc compile { fillLast: true }
/Users/ttn/labs/ttn_web/node_modules/speed-measure-webpack-plugin/index.js:104
        throw new Error("No matching event!");
        ^

Error: No matching event!
    at SpeedMeasurePlugin.addTimeEvent (/Users/ttn/labs/ttn_web/node_modules/speed-measure-webpack-plugin/index.js:104:15)
    at Compiler.compiler.plugin (/Users/ttn/labs/ttn_web/node_modules/speed-measure-webpack-plugin/index.js:118:12)
    at Compiler.applyPlugins (/Users/ttn/labs/ttn_web/node_modules/tapable/lib/Tapable.js:61:14)
    at /Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:271:13
    at Compiler.emitRecords (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:367:37)
    at /Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:265:12
    at /Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:360:11
    at next (/Users/ttn/labs/ttn_web/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/ttn/labs/ttn_web/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:357:8)
    at Compiler.<anonymous> (/Users/ttn/labs/ttn_web/node_modules/webpack/lib/Compiler.js:352:14)
    at /Users/ttn/labs/ttn_web/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/Users/ttn/labs/ttn_web/node_modules/async/dist/async.js:1050:13)
    at /Users/ttn/labs/ttn_web/node_modules/async/dist/async.js:958:16
    at /Users/ttn/labs/ttn_web/node_modules/graceful-fs/graceful-fs.js:43:10

with the following webpack config:

const config = {
    entry: {
      app: ['babel-polyfill', './src/index.js'],
        vendor: ['react', 'react-dom']
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    module: {
        rules: [
            // {
            //     test: /\.json$/,
            //     exclude: [
            //         path.resolve(__dirname, 'node_modules'),
            //     ],
            //     loader: 'json-loader'
            // },
            {
                test: /.(jsx|js)?$/,
                exclude: [
                    path.resolve(__dirname, 'node_modules'),
                ],
                loader: 'babel-loader',
            },
            {
                test: /.(scss|css)$/,
                use: ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    //resolve-url-loader may be chained before sass-loader if necessary
                    use: [{loader: 'css-loader'}, {loader: 'sass-loader', options: {includePaths: [ './node_modules/bourbon' ]}}]
                }),
            },
            {
                test: /\.(otf|png|jpg|jpeg|gif|ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                use: 'url-loader?limit=10000',
            },
            {
                test: /\.yaml$/,
                use: [
                    {loader: 'json-loader'},
                    {loader: 'yaml-loader'},
                ]
            },
            {
                test: /\.html$/,
                loader: 'html-loader'
            }
        ]
    },
    resolve: {
        alias: {
            utils: path.resolve(__dirname, './src/utils'),
            constants: path.resolve(__dirname, './src/constants'),
            components: path.resolve(__dirname, './src/app/components'),
            containers: path.resolve(__dirname, './src/app/containers'),
            core: path.resolve(__dirname, './src/app/core'),
            lodashC: path.resolve(__dirname, './src/js/lodash.custom.min.js')
        },
        extensions: ['.js', '.jsx'],
    },
    devtool: 'source-map',
    plugins: [
        // new CleanWebpackPlugin(pathsToClean, cleanOptions),
        // new BundleAnalyzerPlugin(),
        new ExtractTextPlugin({
            filename:'style.css',
            disable: false
        }),
        new webpack.optimize.CommonsChunkPlugin({
            names: 'vendor',
            filename: 'vendor.js'
        }),
        new webpack.DefinePlugin({
            'VENDOR': JSON.stringify(process.env.VENDOR),
            'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
            "process.env": {
                "NODE_ENV": JSON.stringify(process.env.NODE_ENV),
            }
        }),
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: 'src/index.html'
        }),
        new LiveReloadPlugin(),
        new WebpackBrowserPlugin({
            port: 3000,
            url: 'http://127.0.0.1'
        }),
    ]
};

module.exports = smp.wrap(config);

webpack version - 2.6
smp version - 1.1.3

Incompatibility with 'autodll-webpack-plugin'

image

webpack.config.js

    plugins.push(new AutoDllPlugin({
      inject: true,
      filename: '[name]_[hash:8].js',
      debug: true,
      path: './dll',
      entry: {
        vendor: [
          'vue-router',
          'vuex',
          'nprogress',
        ],
      },
    }));

Swish UX dashboard

It can be quite hard to compare at a glance some of the output, and this is definitely the sort of thing that a swish ux would help with

An optional parameter should turn on some dashboard on localhost showing you more visually the timing information of the loaders and plugins

loaders is undefined for ExternalModule

Hello!
Getting the error TypeError: Cannot read property 'length' of undefined from speed-measure-webpack-plugin/utils.js:50 when I have an externals key in my webpack.config.js

  externals: {
    analytics: 'analytics',
    jquery: 'jQuery'
  }

It seems ExternalModule is wrapping NormalModule inside the issuer key and the top level ExternalModule doesn't have a loaders key.

general output time and modules with no loaders

during start i can see that modules with no loaders is the most expensive part but i have no more detail about that, which are the modules without loader?:

 SMP  ⏱
General output time took 31.27 secs

 SMP  ⏱  Plugins
Object took 0.016 secs
ProvidePlugin took 0.001 secs

 SMP  ⏱  Loaders
modules with no loaders took 15.96 secs
  module count = 6838
babel-loader took 4.42 secs
  module count = 107
css-loader took 2.26 secs
  module count = 16
underscore-template-loader took 1.11 secs
  module count = 24
json-loader took 0.636 secs
  module count = 2
file-loader took 0.151 secs
  module count = 11
style-loader, and
css-loader took 0.012 secs
  module count = 5

during reload my worst loading time comes from general output time:


 SMP  ⏱
General output time took 6.079 secs

 SMP  ⏱  Plugins
Object took 0.005 secs
ProvidePlugin took 0 secs

 SMP  ⏱  Loaders
babel-loader took 0.294 secs
  module count = 1

what does it mean? is it the time spent to compile my own code? how can i figure out the optimization for this?

webpack v1, v2 support

Currently only webpack v3 has been tested

webpack v1 and v2 should be tested, and if plausible, given support for

memory report

does it make sense to also show the memory consumption of each plugin?

Easy `disable` flag

There should be an easy way to disable this plugin entirely, without having to entirely remove it from your config

This plugin does not work with my build!

Hey !

We're suffering from long build time and we'd like to use this plugin to see what's what.
However, i can't make it work with my build.

i'm running npm run build which runs NODE_ENV=production webpack --config config/webpack.prod.config.js -p

Our webpack.prod.config.js looks like this ...


let merge = require('webpack-merge');
let webpack = require('webpack');
let CompressionPlugin = require("compression-webpack-plugin");
let CopyWebpackPlugin = require('copy-webpack-plugin');
let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');
const packageJson = require('../package.json');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");

const smp = new SpeedMeasurePlugin();
const finalConfig = merge.smartStrategy(
    {
        plugins: 'replace', // or 'replace', defaults to 'append'
    }
)(
    require('./webpack.config'),
    {
        mode: "production",
        entry: path.resolve('./src/app.ts'),
        output: {
            filename: "build.[hash].js"
        },
        devtool: false,
        plugins: smp.wrap({
            plugins: [
                new VueLoaderPlugin(),
                new webpack.DefinePlugin({
                    'process.env.NODE_ENV': '"production"',
                    'API_URL': JSON.stringify('MOM_PROD_URL'),
                    'XAVIER_URL': `"${process.env.XAVIER_URL || "http://localhost:3000"}"`,
                    'FRY_VERSION': JSON.stringify(packageJson.version),
                    'FRY_BUILD_TIMESTAMP': JSON.stringify(new Date().getTime())
                }),
                new webpack.NoEmitOnErrorsPlugin(),
                new webpack.ProvidePlugin({
                    $: "jquery",
                    jQuery: "jquery",
                    "window.jQuery": "jquery"
                }),
                new CompressionPlugin({
                    asset: "[path].gz[query]",
                    algorithm: "gzip",
                    test: /\.js$/,
                    threshold: 10240,
                    minRatio: 0.8
                }),
                new CopyWebpackPlugin([
                    {
                        from: path.resolve(__dirname, '../static'),
                    }, {
                        from: path.resolve(__dirname, '../config/defaultapiconfig.js'),
                        to: 'public/config.js'
                    }
                ], {
                    copyUnmodified: true
                }),
                new HtmlWebpackPlugin({
                    title: '[you don't need to know that]',
                    filename: "index.html",
                    template: path.resolve('./config/index.ejs'),
                    inject: false
                })
            ]
        })
    }
);
console.log(JSON.stringify(finalConfig));
module.exports = finalConfig;

A console .log on the config renders this ...

   "entry":"/home/clement/workspace/[you don't need to know that]/v3/fry/src/app.ts",
   "mode":"production",
   "output":{
      "path":"/home/clement/workspace/[you don't need to know that]/v3/fry/dist",
      "filename":"build.[hash].js",
      "globalObject":"this"
   },
   "resolve":{
      "extensions":[
         ".ts",
         ".tsx",
         ".js"
      ]
   },
   "module":{
      "rules":[
         {
            "test":{

            },
            "loader":"vue-loader",
            "options":{
               "esModule":true
            }
         },
         {
            "test":{

            },
            "loader":"babel-loader",
            "exclude":{

            }
         },
         {
            "test":{

            },
            "exclude":{

            },
            "use":[
               {
                  "loader":"babel-loader"
               },
               {
                  "loader":"ts-loader",
                  "options":{
                     "appendTsSuffixTo":[
                        {

                        }
                     ]
                  }
               }
            ]
         },
         {
            "test":{

            },
            "use":[
               "style-loader",
               {
                  "loader":"css-loader",
                  "options":{
                     "minimize":{
                        "zindex":false
                     },
                     "sourceMap":true
                  }
               }
            ]
         },
         {
            "test":{

            },
            "use":[
               "style-loader",
               "vue-style-loader",
               {
                  "loader":"css-loader",
                  "options":{
                     "minimize":{
                        "zindex":false
                     }
                  }
               },
               "resolve-url-loader",
               "sass-loader?sourceMap"
            ]
         },
         {
            "test":{

            },
            "use":{
               "loader":"worker-loader",
               "options":{
                  "publicPath":"/"
               }
            }
         },
         {
            "test":{

            },
            "loader":"url-loader"
         },
         {
            "test":{

            },
            "loader":"file-loader",
            "options":{
               "name":"[hash].[ext]",
               "publicPath":"/assets",
               "outputPath":"/assets"
            }
         }
      ]
   },
   "plugins":{
      "plugins":[
         {

         },
         {
            "definitions":{
               "process.env.NODE_ENV":"\"production\"",
               "API_URL":"\"MOM_PROD_URL\"",
               "XAVIER_URL":"\"http://localhost:3000\"",
               "FRY_VERSION":"\"3.9.7\"",
               "FRY_BUILD_TIMESTAMP":"1539188452896"
            }
         },
         {

         },
         {
            "definitions":{
               "$":"jquery",
               "jQuery":"jquery",
               "window.jQuery":"jquery"
            }
         },
         {
            "options":{
               "asset":"[path].gz[query]",
               "test":{

               },
               "filename":false,
               "compressionOptions":{
                  "level":9
               },
               "cache":false,
               "threshold":10240,
               "minRatio":0.8,
               "deleteOriginalAssets":false
            }
         },
         {

         },
         {
            "options":{
               "template":"/home/clement/workspace/[you don't need to know that]/v3/fry/config/index.ejs",
               "filename":"index.html",
               "hash":false,
               "inject":false,
               "compile":true,
               "favicon":false,
               "minify":false,
               "cache":true,
               "showErrors":true,
               "chunks":"all",
               "excludeChunks":[

               ],
               "chunksSortMode":"auto",
               "meta":{

               },
               "title":"[you don't need to know that]",
               "xhtml":false
            }
         },
         {
            "options":{

            },
            "timeEventData":{

            },
            "smpPluginAdded":true
         }
      ]
   },
   "devtool":false
}

So the console spits this kind of error (the full stack trace is too long obviously...)

ERROR in ./src/conceptor/datasources/components/DatasourceForm.vue?vue&type=script&lang=ts& 95:8
Module parse failed: Unexpected token (95:8)
You may need an appropriate loader to handle this file type.
| import {renamePath} from "../../../common/utils/Datasources";
| 
> declare const API_URL: String;
| 
| export default {
 @ ./src/conceptor/datasources/components/DatasourceForm.vue 2:0-66 3:0-61 3:0-61 10:2-8
 @ ./src/conceptor/datasources/components/DatasourcePanel.vue?vue&type=script&lang=ts&
 @ ./src/conceptor/datasources/components/DatasourcePanel.vue
 @ ./src/components.ts
 @ ./src/app.ts

The console.log does not show everything but it seems that it should work fine.

Any idea what could go wrong?

No hook for filter absMids in object NormalModuleFactory

The project I'm working with is utilizing the dojo-webpack-plugin and when running with the speed-measure-webpack-plugin, I get the following error during the build:

C:\myapp\node_modules\webpack-plugin-compat\lib\pluginCompatV4.js:124
                throw new Error(`No hook for ${name} in object ${obj.constructor.name}`);
                ^

Error: No hook for filter absMids in object NormalModuleFactory
    at callHook (C:\myapp\node_modules\webpack-plugin-compat\lib\pluginCompatV4.js:124:9)
    at callSync (C:\myapp\node_modules\webpack-plugin-compat\lib\pluginCompatV4.js:137:10)
    at DojoAMDModuleFactoryPlugin.module (C:\myapp\node_modules\dojo-webpack-plugin\lib\DojoAMDModuleFactoryPlugin.js:225:4)
    at SyncWaterfallHook.eval [as call] (eval at create (C:\myapp\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:16)
    at hooks.afterResolve.callAsync (C:\myapp\node_modules\webpack\lib\NormalModuleFactory.js:153:40)
    at AsyncSeriesWaterfallHook.eval [as callAsync] (eval at create (C:\myapp\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:66:1)
    at resolver (C:\myapp\node_modules\webpack\lib\NormalModuleFactory.js:138:29)
    at resolver (C:\myapp\node_modules\dojo-webpack-plugin\lib\DojoAMDModuleFactoryPlugin.js:199:5)
    at process.nextTick (C:\myapp\node_modules\webpack\lib\NormalModuleFactory.js:342:9)
    at process._tickCallback (internal/process/next_tick.js:61:11)

Error in Webpack 3.1.1.0

node_modules/webpack/lib/Stats.js:273
                                        size: compilation.assets[asset].size(),
                                                                        ^
TypeError: compilation.assets[asset].size is not a function
    at obj.assets.compilationAssets.map.asset (node_modules/webpack/lib/Stats.js:273:38)
    at Array.map (<anonymous>)
    at Stats.toJson (node_modules/webpack/lib/Stats.js:270:35)
    at Proxy.<anonymous> (node_modules/webpack-visualizer-plugin/lib/plugin.js:45:52)
    at Compiler.wrappedFunc (node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:26:24)
    at Compiler.applyPluginsAsyncSeries (node_modules/tapable/lib/Tapable.js:206:13)
    at Compiler.emitAssets (node_modules/webpack/lib/Compiler.js:354:8)
    at onCompiled (node_modules/webpack/lib/Compiler.js:58:19)
    at applyPluginsAsync.err (node_modules/webpack/lib/Compiler.js:510:14)
    at next (node_modules/tapable/lib/Tapable.js:202:11)
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh

And my webpack.config.dev.js:

'use strict';

const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const StatsPlugin = require('stats-webpack-plugin');
const Visualizer = require('webpack-visualizer-plugin');
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");

const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');

const publicPath = '/';
const publicUrl = '';
const env = getClientEnvironment(publicUrl);

process.traceDeprecation = true;
const smp = new SpeedMeasurePlugin();

module.exports = smp.wrap({
  cache: true,
  devtool: 'inline-eval-cheap-source-map',
  entry: [
    require.resolve('react-dev-utils/webpackHotDevClient'),
    require.resolve('./polyfills'),
    'bootstrap-loader',
    paths.appIndexJs
  ],
  output: {
    path: paths.appBuild,
    pathinfo: true,
    filename: 'static/js/bundle.js',
    publicPath: publicPath
  },
  resolve: {
    modules: [
      'app',
      'node_modules'
    ],
    extensions: ['.js', '.json', '.jsx', '.react.js'],
    alias: {
      'react-native': 'react-native-web'
    }
  },

  module: {
    rules: [
      {
        enforce: 'pre',
        test: /\.(js|jsx)$/,
        use: [
          {
            loader: 'eslint-loader'
          }
        ],
        include: paths.appSrc,
      },

      {
        exclude: [
          /\.html$/,
          /\.(js|jsx)(\?.*)?$/,
          /\.css$/,
          /\.gif$/,
          /\.jpg$/,
          /\.json$/,
          /\.png$/,
          /\.scss$/,
          /\.svg$/
        ],
        use: [
          {
            loader: 'url-loader',
            query: {
              limit: 10000,
              name: 'static/media/[name].[hash:8].[ext]'
            }
          }
        ]
      },
      {
        test: /\.(js|jsx)$/,
        include: [paths.appSrc, paths.appNodeModules + '/webgl-render-library'],
        use: [
          {
            loader: 'babel-loader',
            query: {
              cacheDirectory: true
            }
          }
        ]
      },
      {
        test: /\.css$/,
        include: /node_modules/,
        loader: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: 'raw-loader!postcss-loader',
        })
      },
      {
        test: /\.scss$/,
        include: paths.appSrc,
        use: [
          'style-loader',
          'raw-loader',
          'postcss-loader',
          'fast-sass-loader',
          {
            loader: 'sass-resources-loader',
            options: {
              resources: [path.resolve(__dirname, '../config/sass-resources.scss')],
            },
          },
        ]
      },
      {
       test: /\.(eot|woff|ttf|svg|png|jpg|gif)$/,
       loader: 'url-loader?limit=30000&name=[name]-[hash].[ext]'
      },
      {
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.svg$/,
        use: [
          {
            loader: 'file-loader',
            query: {
              name: 'static/media/[name].[hash:8].[ext]'
            }
          }
        ]
      },
      {
        test: /\.(png|jpg)$/,
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 25000
            }
          }
        ]
      }
    ]
  },

  plugins: [
    new Visualizer(),

    new BundleAnalyzerPlugin({
      analyzerMode: 'server'
    }),

    new StatsPlugin('stats.json', {
      chunkModules: true,
    }),

    new webpack.optimize.ModuleConcatenationPlugin(),

    new webpack.optimize.CommonsChunkPlugin({
      name: 'app',
      filename: "app.js",
      minChunks: function(module, count) {
        const match = module.context && !module.context.includes('node_modules') && !module.context.includes('/game/');
        return match;
      }
    }),

    new ExtractTextPlugin({
      filename: 'styles.css',
      allChunks: true
    }),

    new webpack.LoaderOptionsPlugin({
      options: {
        postcss: [autoprefixer],
        context: __dirname,
      },
    }),

    new InterpolateHtmlPlugin(env.raw),
    new HtmlWebpackPlugin({
      inject: true,
      template: paths.appHtml,
    }),
    new webpack.DefinePlugin(env.stringified),
    new webpack.HotModuleReplacementPlugin(),
    new CaseSensitivePathsPlugin(),
    new WatchMissingNodeModulesPlugin(paths.appNodeModules)
  ],
  node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty'
  },
  devServer: {
    stats: 'verbose',
    profile: true,
  },
});

How to use with Neutrino

It looks like this plugin goes in an wraps other plugins by processing the entire webpack config.

I'm looking at using this in neutrino, which uses webpack-chain to perform adjustments on the webpack config. I'm wondering if there are any examples of using this with that set up already... otherwise it looks like I might be putting my one together.

How to use in nuxt.js project?

I'm trying to use the plugin in a nuxt.js project, but I can't get it to work.

In my nuxt.config.js, I've added

import SpeedMeasurePlugin from 'speed-measure-webpack-plugin';

const smp = new SpeedMeasurePlugin();

module.exports = {
    ...,
    build: {
        ...,
        extend(config, { isDev }) {
            if (isDev) {
                return smp.wrap(config);
            }
        }
    },
    ...
}

But when running nuxt from the command line, SMP doesn't print anything. Any tips?

webpack v4 support

webpack v4 compatibility needs to be added (as this plugin won't work properly with v4 atm)

Error when using happypack

Just tried adding this and running and got this error:

ERROR in ./src/apps/3dviewer/webpack-entry.js
Module build failed: AssertionError: HappyPack: plugin for the loader '1' could not be found! Did you forget to add it to the plugin list?
    at Object.HappyLoader (/Users/cjw/work/fictiv-js/node_modules/happypack/lib/HappyLoader.js:37:3)
 @ multi ./src/lib/baseConfig ./src/apps/3dviewer/webpack-entry.js

I can try to add a more complete set of config sometime this weekend or monday.

Add colour stripping support

Currently the ANSI colour codes are stripped out for when routing to a file, but no option is given to strip out the colours otherwise

This can cause some tools like Jenkins to have a messy output, if they don't have ANSI control code support (which Jenkins doesn't have by default, and needs this plugin to add it)

Mysterious output with webpack 4 and style related loaders

I'm using latest versions of everything: webpack, loaders & speed-measure-webpack-plugin.
I run webpack build with production config and got this result

41343887-f6e55208-6f29-11e8-8937-f181d445a18f

I don't understand why and what should I do to optimize (prevent duplicate???)

Cannot read property 'hash' of undefined

"html-webpack-plugin": "^4.0.0-beta.2",

get error:

Failed to compile:

TypeError: Cannot read property 'hash' of undefined

  • compiler.js:292 childCompiler.compileTemplates.then
    [imt]/[html-webpack-plugin]/lib/compiler.js:292:30

  • next_tick.js:68 process._tickCallback
    internal/process/next_tick.js:68:7

  • loader.js:745 Function.Module.runMain
    internal/modules/cjs/loader.js:745:11

  • node.js:279 startup
    internal/bootstrap/node.js:279:19

  • node.js:752 bootstrapNodeJSCore
    internal/bootstrap/node.js:752:3

Add time comparison

Some kind of time comparison would be awesome. The plugin could save the last build times and compare to them. This should make optimizing easier as you can see what times have changed based on your modifications.

AutoDllPlugin incompatibility

Currently the AutoDllPlugin is incompatible with this plugin

It looks like an issue with the Proxy set-up on our end

functional tests

There should be a suite of tests, that test various webpack versions and plugins etc. in order to ensure compatibility of SMP with these

TypeError: Cannot read property 'tap' of undefined

It seems that can't work with webpack customed hooks such as html-webpack-plugin-before-html-processing in html-webpack-plugin, when we tap these events, the error occurred.

compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing.tap(... 
                                                        ^
TypeError: Cannot read property 'tap' of undefined

Breaks with incremental builds

Several plugins I have tried to use alongside this plugin break when webpack starts an incremental build after a code change. The issue seems to be that all the hooks registered on the webpack 4 compiler.hooks object are missing in the incremental compile. The plugins then fail with errors like TypeError: Cannot read property 'call' of undefined. Removing the speed-measure-webpack-plugin fixes the issue.

Enabling the plugin causes a significant build performance regression

Hi Stephen,

This seemed like a pretty useful concept, however - when I tried it and enabled the plugin, the build times went from 160 seconds to over 1000 seconds for a full build of our app.

This means that just having the plugin enabled, has caused over a 6x regression in speed. Additionally, the times it measured did not seem accurate, e.g. a plugin which simply adds a property to some modules was measured to have taken 40 seconds (I don't think it's possible that adding a property, even if to over 8000 modules, should take this much time).

Any ideas on what might be going wrong?

webpack-merge support

Currently there's no great way to use this plugin if trying to work with multiple plugins being merged (e.g. with webpack-merge)

This plugin should play nicely with plugin merging

missing: how long does speed measure webpack plugin take?

Sample output:

 SMP  ⏱
General output time took 16.54 secs

 SMP  ⏱  Plugins
HtmlWebpackPlugin took 2.1 secs
WatchMissingNodeModulesPlugin took 1.45 secs
HotModuleReplacementPlugin took 0.615 secs
IgnorePlugin took 0.056 secs
CaseSensitivePathsPlugin took 0.018 secs
InterpolateHtmlPlugin took 0.016 secs
NamedModulesPlugin took 0.012 secs
DefinePlugin took 0.005 secs

 SMP  ⏱  Loaders
ngtemplate-loader, and
html-loader took 0.955 secs
  module count = 1

Notice how the general output time takes 16.54 s, but if we look at the plugins, we are missing 14 seconds. Note that the difference is easily noticeable when reproducing #35.

Node support

There's no good reason to limit our node support. We should support as low a node version as webpack 4 supports

Module parse failed: Maximum call stack size exceeded

Awesome plugin (1.1.1), but I run into the following error in my webpack (3.11.0) build [node 8.10.0]:

    ERROR in ./node_modules/lodash/lodash.js
    Module parse failed: Maximum call stack size exceeded
    You may need an appropriate loader to handle this file type.
    RangeError: Maximum call stack size exceeded
        at Function.keys (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:57:33)
        at Object.get (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:90:14)
        at Object.keys.map.k (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:19)
        at Array.map (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:6)
        at Object.get (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:90:14)
        at Object.keys.map.k (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:19)
        at Array.map (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:6)
        at Object.get (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:90:14)
        at Object.keys.map.k (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:19)
        at Array.map (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:6)
        at Object.get (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:90:14)
        at Object.keys.map.k (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:19)
        at Array.map (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:6)
        at Object.get (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:90:14)
        at Object.keys.map.k (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:19)
        at Array.map (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:6)
        at Object.get (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:90:14)
        at Object.keys.map.k (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:19)
        at Array.map (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:6)
        at Object.get (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:90:14)
        at Object.keys.map.k (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:19)
        at Array.map (<anonymous>)
        at wrap (/Website_Server/t47io/main/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:58:6)
     @ ./node_modules/html-webpack-plugin/lib/loader.js!./applications/index.html 1:8-51

Note, it's not about lodash, I got this error hundreds of times basically for everything, loaders, etc. I do get the SMP outputs though (before webpack summary prints), but the build fails because of these errors. Any ideas?

Would you recommend this for webpack-dev-server / webpack --watch?

I notice with speed-measure-webpack-plugin on, there is a memory leak over time:

Note I have about 2000 modules roughly (file is about 5 mbs)
Test i did was the following on a file:

console.log('sdsdssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss')

Memory starts at 977mb, rises all the way to 1.6 gbs after a bunch of saves (so every s above there is a save^), then gives the following error:

<--- Last few GCs --->

[36905:0x102801600]   326069 ms: Mark-sweep 1421.1 (1555.1) -> 1413.8 (1555.1) MB, 446.3 / 0.0 ms  allocation failure GC in old space requested
[36905:0x102801600]   326622 ms: Mark-sweep 1413.8 (1555.1) -> 1413.7 (1509.6) MB, 553.1 / 0.0 ms  last resort
[36905:0x102801600]   327136 ms: Mark-sweep 1413.7 (1509.6) -> 1413.7 (1499.1) MB, 513.5 / 0.0 ms  last resort


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x23ce3779cca1 <JSObject>
    2: fromString(aka fromString) [buffer.js:308] [bytecode=0x10cb92da4d61 offset=202](this=0x23ce37782241 <undefined>,string=0x1860f1eefe9 <Very long string[5010042]>,encoding=0x23ce377fe311 <String[4]: utf8>)
    4: from [buffer.js:173] [bytecode=0x10cb92da4851 offset=11](this=0xc2a75ec4ae1 <JSFunction Buffer (sfi = 0x23b0d14b8981)>,value=0x1860f1eefe9 <Very long string[5010042]>,encodingOrOff...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 5: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 6: v8::String::WriteUtf8(char*, int, int*, int) const [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 7: node::StringBytes::Write(v8::Isolate*, char*, unsigned long, v8::Local<v8::Value>, node::encoding, int*) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 8: node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
 9: node::Buffer::(anonymous namespace)::CreateFromString(v8::FunctionCallbackInfo<v8::Value> const&) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
10: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
11: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
12: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [~/hrgui.nvm/versions/node/v8.3.0/bin/node]
13: 0x30c8e12040dd

Confusing multiple loader output

Loaders such as css-loader w/ ExtractTextPlugin etc. can have confusing multiple / duplicate outputs.
This is completely expected (as mentioned in #47) - but is confusing.

It would be good to either think of a way of outputting this that is less confusing, or perhaps just pushing e.g. the granularLoaderData experimental flag

Is this compatible with Webpack 4.16.5?

I tried installing this today, but Webpack just hung indefinitely and produced no output.

I didn't have time to debug it any further, and my config is a bit of a mess, so I just wanted to check if there's anything in general that would cause a silent hang like this?

Breaks with HtmlWebpackHarddiskPlugin & BaseHrefWebpackPlugin

Hey!

Thanks for this project :)

I ran into issues that are maybe related to #44:
When including HtmlWebpackHarddiskPlugin and/or BaseHrefWebpackPlugin I get the following errors:

HtmlWebpackHarddiskPlugin:

TypeError: HtmlWebpackPlugin.getHooks is not a function
    at Proxy.<anonymous> ([...]node_modules/html-webpack-harddisk-plugin/index.js:24:39)
    at args ([...]node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:52:19)
    at SyncHook.eval (eval at create ([...]node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:15:1)
    at SyncHook.lazyCompileHook ([...]node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.newCompilation ([...]node_modules/webpack/lib/Compiler.js:503:26)
    at hooks.beforeCompile.callAsync.err ([...]node_modules/webpack/lib/Compiler.js:539:29)
    at AsyncSeriesHook.eval [as callAsync] (eval at create ([...]node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook ([...]node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.compile ([...]node_modules/webpack/lib/Compiler.js:534:28)
    at readRecords.err ([...]node_modules/webpack/lib/Compiler.js:274:11)
    at Compiler.readRecords ([...]node_modules/webpack/lib/Compiler.js:401:11)
    at hooks.run.callAsync.err ([...]node_modules/webpack/lib/Compiler.js:271:10)
    at _err0 (eval at create ([...]node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:20:1)
    at func.apply.argsButLast.map.concat.callbackArgs ([...]node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:44:9)
    at Proxy.<anonymous> ([...]node_modules/awesome-typescript-loader/src/watch-mode.ts:7:4)
    at args ([...]node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:40:16)

BaseHrefWebpackPlugin:

TypeError: Cannot read property 'tapAsync' of undefined
    at Proxy.tapAsync ([...]node_modules/base-href-webpack-plugin/index.js:12:63)
    at args ([...]node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:52:19)
    at SyncHook.eval (eval at create ([...]node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:15:1)
    at SyncHook.lazyCompileHook ([...]node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.newCompilation ([...]node_modules/webpack/lib/Compiler.js:503:26)
    at hooks.beforeCompile.callAsync.err ([...]node_modules/webpack/lib/Compiler.js:539:29)
    at AsyncSeriesHook.eval [as callAsync] (eval at create ([...]node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook ([...]node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.compile ([...]node_modules/webpack/lib/Compiler.js:534:28)
    at readRecords.err ([...]node_modules/webpack/lib/Compiler.js:274:11)
    at Compiler.readRecords ([...]node_modules/webpack/lib/Compiler.js:401:11)
    at hooks.run.callAsync.err ([...]node_modules/webpack/lib/Compiler.js:271:10)
    at _err0 (eval at create ([...]node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:20:1)
    at func.apply.argsButLast.map.concat.callbackArgs ([...]node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:44:9)
    at Proxy.<anonymous> ([...]node_modules/awesome-typescript-loader/src/watch-mode.ts:7:4)
    at args ([...]node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:40:16)
`webpack.config.js` (With both plugins enabled)

{
  "devtool": false,
  "entry": {
    "app": [
      "@babel/polyfill",
      "[...]/src/app/index.jsx"
    ]
  },
  "mode": "production",
  "module": {
    "rules": [
      {
        "oneOf": [
          {
            "test": [
              {},
              {},
              {},
              {}
            ],
            "use": [
              {
                "loader": "url-loader",
                "options": {
                  "limit": 1000,
                  "fallback": "file-loader",
                  "name": "assets/[path][name].[hash:8].[ext]",
                  "publicPath": "/nachrichten"
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "babel-loader",
                "options": {
                  "presets": [
                    [
                      "[...]/node_modules/@babel/preset-env/lib/index.js",
                      {
                        "modules": "commonjs",
                        "targets": {
                          "browsers": [
                            "last 2 versions",
                            "ie >= 11"
                          ]
                        }
                      }
                    ],
                    "[...]/node_modules/@babel/preset-react/lib/index.js",
                    "[...]/node_modules/@babel/preset-flow/lib/index.js"
                  ],
                  "plugins": [
                    "[...]/node_modules/babel-plugin-macros/dist/index.js",
                    "[...]/node_modules/@babel/plugin-transform-runtime/lib/index.js",
                    [
                      "[...]/node_modules/babel-plugin-transform-react-remove-prop-types/lib/index.js",
                      {
                        "mode": "unsafe-wrap"
                      }
                    ],
                    [
                      "[...]/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
                      {
                        "loose": true
                      }
                    ],
                    "[...]/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
                    "[...]/node_modules/babel-plugin-minify-dead-code-elimination/lib/index.js",
                    "[...]/node_modules/babel-plugin-idx/lib/babel-plugin-idx.js",
                    "[...]/node_modules/babel-plugin-relay/index.js",
                    "[...]/node_modules/react-loadable/babel.js",
                    [
                      "[...]/node_modules/babel-plugin-styled-components/lib/index.js",
                      {
                        "displayName": true,
                        "preprocess": false,
                        "ssr": true
                      }
                    ]
                  ]
                }
              }
            ],
            "exclude": {}
          },
          {
            "test": {},
            "use": [
              {
                "loader": "babel-loader",
                "options": {
                  "presets": [
                    [
                      "[...]/node_modules/@babel/preset-env/lib/index.js",
                      {
                        "modules": "commonjs",
                        "targets": {
                          "browsers": [
                            "last 2 versions",
                            "ie >= 11"
                          ]
                        }
                      }
                    ],
                    "[...]/node_modules/@babel/preset-react/lib/index.js",
                    "[...]/node_modules/@babel/preset-flow/lib/index.js"
                  ],
                  "plugins": [
                    "[...]/node_modules/babel-plugin-macros/dist/index.js",
                    "[...]/node_modules/@babel/plugin-transform-runtime/lib/index.js",
                    [
                      "[...]/node_modules/babel-plugin-transform-react-remove-prop-types/lib/index.js",
                      {
                        "mode": "unsafe-wrap"
                      }
                    ],
                    [
                      "[...]/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
                      {
                        "loose": true
                      }
                    ],
                    "[...]/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
                    "[...]/node_modules/babel-plugin-minify-dead-code-elimination/lib/index.js",
                    "[...]/node_modules/babel-plugin-idx/lib/babel-plugin-idx.js",
                    "[...]/node_modules/babel-plugin-relay/index.js",
                    "[...]/node_modules/react-loadable/babel.js",
                    [
                      "[...]/node_modules/babel-plugin-styled-components/lib/index.js",
                      {
                        "displayName": true,
                        "preprocess": false,
                        "ssr": true
                      }
                    ]
                  ]
                }
              },
              {
                "loader": "ts-loader",
                "options": {
                  "configFile": "[...]/tsconfig.json",
                  "logInfoToStdOut": true
                }
              }
            ],
            "exclude": {}
          },
          {
            "test": {},
            "use": [
              "[...]/node_modules/mini-css-extract-plugin/dist/loader.js",
              {
                "loader": "css-loader",
                "options": {
                  "importLoaders": 2,
                  "localIdentName": "[local]___[hash:base64:5]",
                  "modules": true,
                  "sourceMap": false
                }
              },
              {
                "loader": "postcss-loader",
                "options": {
                  "ident": "postcss",
                  "plugins": [
                    null
                  ],
                  "publicPath": "/nachrichten/assets",
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              "[...]/node_modules/mini-css-extract-plugin/dist/loader.js",
              {
                "loader": "css-loader",
                "options": {
                  "importLoaders": 3,
                  "localIdentName": "[local]___[hash:base64:5]",
                  "modules": true,
                  "sourceMap": false
                }
              },
              {
                "loader": "postcss-loader",
                "options": {
                  "ident": "postcss",
                  "plugins": [
                    null
                  ],
                  "publicPath": "/nachrichten/assets",
                  "sourceMap": false
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              "[...]/node_modules/mini-css-extract-plugin/dist/loader.js",
              {
                "loader": "css-loader",
                "options": {
                  "importLoaders": 3,
                  "localIdentName": "[local]___[hash:base64:5]",
                  "modules": true,
                  "sourceMap": false
                }
              },
              {
                "loader": "postcss-loader",
                "options": {
                  "ident": "postcss",
                  "plugins": [
                    null
                  ],
                  "publicPath": "/nachrichten/assets",
                  "sourceMap": false
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "html-loader"
              },
              {
                "loader": "markdown-loader"
              }
            ]
          },
          {
            "test": {},
            "oneOf": [
              {
                "issuer": {},
                "use": [
                  {
                    "loader": "url-loader"
                  }
                ]
              },
              {
                "issuer": {},
                "use": [
                  {
                    "loader": "svg-react-loader"
                  }
                ]
              }
            ]
          },
          {
            "exclude": [
              {},
              {},
              {}
            ],
            "use": [
              {
                "loader": "file-loader",
                "options": {
                  "name": "assets/[path][name].[hash:8].[ext]",
                  "publicPath": "/nachrichten"
                }
              }
            ]
          }
        ]
      }
    ]
  },
  "optimization": {
    "minimizer": [
      {
        "options": {
          "test": {},
          "extractComments": false,
          "sourceMap": false,
          "cache": true,
          "parallel": true,
          "uglifyOptions": {
            "output": {
              "comments": {}
            }
          }
        }
      },
      {
        "pluginDescriptor": {
          "name": "OptimizeCssAssetsWebpackPlugin"
        },
        "options": {
          "assetProcessors": [
            {
              "phase": "compilation.optimize-chunk-assets",
              "regExp": {}
            }
          ],
          "assetNameRegExp": {},
          "cssProcessorOptions": {},
          "cssProcessorPluginOptions": {}
        },
        "phaseAssetProcessors": {
          "compilation.optimize-chunk-assets": [
            {
              "phase": "compilation.optimize-chunk-assets",
              "regExp": {}
            }
          ],
          "compilation.optimize-assets": [],
          "emit": []
        },
        "deleteAssetsMap": {}
      }
    ],
    "splitChunks": {
      "cacheGroups": {
        "common": {
          "name": "common",
          "chunks": "async",
          "enforce": true,
          "minChunks": 2,
          "priority": 10,
          "reuseExistingChunk": true
        },
        "lottie": {
          "name": "lottie-web",
          "chunks": "all",
          "priority": 30,
          "test": {}
        },
        "vendors": {
          "name": "vendors",
          "chunks": "all",
          "priority": 20,
          "test": {}
        }
      }
    }
  },
  "output": {
    "filename": "assets/[name]_[contenthash].js",
    "path": "[...]/dist/web",
    "publicPath": "/nachrichten/"
  },
  "performance": {},
  "plugins": [
    {
      "options": {},
      "pathCache": {},
      "fsOperations": 0,
      "primed": false
    },
    {},
    {
      "opts": {
        "publicPath": null,
        "basePath": "",
        "fileName": "manifest.json",
        "transformExtensions": {},
        "writeToFileEmit": false,
        "seed": null,
        "filter": null,
        "map": null,
        "generate": null,
        "sort": null
      }
    },
    {
      "keys": [
        "NODE_ENV",
        "BIND_PORT",
        "BRANCH",
      ],
      "defaultValues": {}
    },
    {
      "options": {}
    },
    {
      "preferEntry": false
    },
    {
      "opts": {
        "filename": "stats.json",
        "fields": null
      }
    },
    {
      "options": {
        "template": "./public/index.html",
        "filename": "index.html",
        "hash": false,
        "inject": true,
        "compile": true,
        "favicon": false,
        "minify": false,
        "cache": true,
        "showErrors": true,
        "chunks": "all",
        "excludeChunks": [],
        "chunksSortMode": "auto",
        "meta": {},
        "title": "Webpack App",
        "xhtml": false
      }
    },
    {},
    {
      "filename": "./dist/web/react-loadable.json"
    },
    {
      "options": {
        "baseHref": "/nachrichten/"
      }
    },
    {
      "options": {
        "filename": "assets/[name]_[contenthash].css",
        "chunkFilename": "assets/[name]_[contenthash].css"
      }
    },
    {
      "options": {
        "name": "Analysis Build (web)",
        "color": "#800087",
        "profile": false,
        "compiledIn": true,
        "done": null,
        "minimal": false,
        "stream": null
      }
    },
    {
      "opts": {
        "analyzerMode": "static",
        "analyzerHost": "127.0.0.1",
        "analyzerPort": 8888,
        "reportFilename": "./reports/bundleAnalyzerReport.html",
        "defaultSizes": "parsed",
        "openAnalyzer": false,
        "generateStatsFile": false,
        "statsFilename": "stats.json",
        "statsOptions": null,
        "excludeAssets": null,
        "logLevel": "silent",
        "startAnalyzer": true
      },
      "server": null,
      "logger": {
        "activeLevels": {}
      }
    },
    {
      "opts": {
        "filename": "./reports/webpackVisualizerReport.html"
      }
    },
    {
      "options": {},
      "timeEventData": {},
      "smpPluginAdded": true
    }
  ],
  "resolve": {
    "extensions": [
      ".js",
      ".jsx",
      ".ts",
      ".tsx",
      ".json",
      ".mjs"
    ],
    "modules": [
      "node_modules"
    ]
  },
  "target": "web"
}

Incompatibility with 'webapp-webpack-plugin'

Hi! I found some incompatibilities when working with both speed-measure-webpack-plugin and webapp-webpack-plugin. When this plugin is enabled, the favicons generated by the webapp-webpack-plugin are not being inserted in the index.html file.

Steps to reproduce:

  • Clone https://github.com/woitechen/tysark.git
  • Run yarn && yarn build
  • Look at dist/index.html. Note that no favicons are included in the header.
  • Run yarn analyze
  • Look at dist/index.html. Favicons!

Note: look at line 214

Optimising modules with no loaders

Hi @stephencookdev ,

Firstly, thanks for developing this plugin. I have a question regarding the Modules with no loaders output.

Our current webpack config produces the following output:

 SMP  ⏱  Loaders
babel-loader took 8.56 secs
  module count = 821
modules with no loaders took 5.3 secs
  module count = 104

I was wondering if and how we can optimize our configuration to skip those 104 modules with no loaders?

Nothing is displayed in terminal

Hi,
I'm trying to use the plugin but it doesn't seem to work with my current configuration.

Environment:
Windows 7
Node: 6.9.1
NPM: 3.10.8
Webpack: 3.10.0

webpack.config.js

/**
 * Identify the environment
 */

const DEV = "dev";
const TEST = "test";
const PROD = "prod";

var isDev = process.env.NODE_ENV === DEV;
var isTest = process.env.NODE_ENV === TEST;
var isProd = process.env.NODE_ENV === PROD;

if (typeof process.env.NODE_ENV === 'undefined') {
  console.log("ERROR: The NODE_ENV environment variable is not defined.");
  console.log("       This environment variable is needed to run this program.");
  console.log("       The value should be either '" + DEV + "' or '" + TEST + "' or '" + PROD + "'.");
  process.exit(-1);
}

if (!isDev && !isTest && !isProd) {
  console.log("ERROR: The NODE_ENV environment variable is not defined correctly.");
  console.log("       The current value is '" + process.env.NODE_ENV + "' (should be either '" + DEV + "' or '" + TEST + "' or '" + PROD + "').");
  process.exit(-1);
}
else {
  console.log("The NODE_ENV environment variable is " + process.env.NODE_ENV);
}
var SpeedMeasurePlugin = require("speed-measure-webpack-plugin");

const smp = new SpeedMeasurePlugin();
// Look in ./config folder for webpack.dev.js
module.exports = smp.wrap(require('./config/webpack.' + process.env.NODE_ENV + '.js'));

And my dev configuration:

/**
 * Webpack Constants
 */
const BRANCH_GUI_PROPERTIES = {
  scheme: 'http',
  host: 'localhost',
  port: '8080'
};

/**
 * Imports
 */
var webpack = require('webpack');
var helpers = require('./helpers');

/**
 * Webpack Plugins
 */
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');



/**
 * Get invoked task
 */
var isBuilding = process.env.npm_lifecycle_event === 'build';

/**
 * Webpack configuration
 *
 * See: http://webpack.github.io/docs/configuration.html#cli
 */

module.exports = {

  // Developer tool to enhance debugging
  //
  // See: http://webpack.github.io/docs/configuration.html#devtool
  // See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
  devtool:'cheap-module-eval-source-map',

  // Cache generated modules and chunks to improve performance for multiple incremental builds.
  // This is enabled by default in watch mode.
  // You can pass false to disable it.
  //
  // See: http://webpack.github.io/docs/configuration.html#cache
  cache: true,

  // The entry point for the bundle
  // Our Angular.js app
  //
  // See: http://webpack.github.io/docs/configuration.html#entry
  entry: {
    'polyfills': './config/polyfills.ts',
    'environment': './config/environment.dev.js',

    'vendor': './config/vendor.dev.ts',
    'app': './src/bootstrap/dev.bootstrap.ts' // our angular app
  },

  // Options affecting the resolving of modules.
  //
  // See: http://webpack.github.io/docs/configuration.html#resolve
  resolve: {

    modules: [helpers.root('src'), helpers.root('node_modules'), helpers.root('libs')],

    // An array of extensions that should be used to resolve modules.
    //
    // See: http://webpack.github.io/docs/configuration.html#resolve-extensions
    extensions: ['.ts', '.js', '.json', '.css', '.scss', '.html'],
//      'pdf-designer': helpers.root('libs/pdf-designer/index.js'),


    alias: {
      'app': 'src/app',
      'common': 'src/common',
      'moment':'moment/moment.js',
      'file-saver':'file-saver/FileSaver.js',
      'jspdf': 'jspdf/dist/jspdf.min.js',
      'pdfjs': 'pdfjs-dist/build/pdf.js',
      'pdfViewer' : 'pdfjs-dist/web/pdf_viewer',
      'pdf-designer': 'pdf-designer/index.js',
      'socket.io-client':'socket.io-client/dist/socket.io.js',
      'uuid-random':'uuid-random/uuid-random.min.js',
      'xlsx':'xlsx/xlsx.js',
    }
  },

  // Options affecting the output of the compilation.
  //
  // See: http://webpack.github.io/docs/configuration.html#output
  output: {

    // The output directory as absolute path (required).
    //
    // See: http://webpack.github.io/docs/configuration.html#output-path
    path: helpers.root('dist'),

    // test
    pathinfo: true,

    publicPath: isBuilding ? '' : BRANCH_GUI_PROPERTIES.scheme + '://' + BRANCH_GUI_PROPERTIES.host + ':' + BRANCH_GUI_PROPERTIES.port + '/',

    // Specifies the name of each output file on disk.
    // IMPORTANT: You must not specify an absolute path here!
    //
    // See: http://webpack.github.io/docs/configuration.html#output-filename
    filename: 'js/[name].js',

    // The filename of non-entry chunks as relative path
    // inside the output.path directory.
    //
    // See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
    chunkFilename: '[id].chunk.js'

  },

  // Options affecting the normal modules.
  //
  // See: http://webpack.github.io/docs/configuration.html#module
  module: {

    // An array of applied pre and post loaders.
    //
    // See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders

    // An array of automatically applied loaders.
    //
    // IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
    // This means they are not resolved relative to the configuration file.
    //
    // See: http://webpack.github.io/docs/configuration.html#module-loaders
    rules: [
      // Support for .ts files.
      /*{
        test: /\.ts$/,
        enforce: 'pre',
        loader: 'tslint-loader'
      },*/
      {
        test: /\.ts$/,
        use: ['awesome-typescript-loader', 'angular2-template-loader', 'angular2-router-loader', '@angularclass/hmr-loader'],
        exclude: /node_modules/
      },

      // copy those assets to output
      {test: /\.png|\.jpe?g|\.gif|\.svg|\.woff|\.woff2|\.ttf|\.eot|\.ico|\.svg$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]?'},

      // Support for *.json files.
      {test: /\.json$/, loader: 'json-loader'},

      // Support for CSS as raw text
      // use 'null' loader in test mode (https://github.com/webpack/null-loader)
      // all css in src/style will be bundled in an external css file
      {
        test: /\.css$/,
        exclude: helpers.root('src', 'app'),
        loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader', 'postcss-loader']})
      },
      // all css required in src/app files will be merged in js files
      {test: /\.css$/, include: helpers.root('src', 'app'), loader: 'raw-loader!postcss-loader'},

      // support for .scss files
      // use 'null' loader in test mode (https://github.com/webpack/null-loader)
      // all css in src/style will be bundled in an external css file
      {
        test: /\.scss$/,
        exclude: helpers.root('src', 'app'),
        loader: ['extracted-loader'].concat(ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader', 'postcss-loader','sass-loader'], publicPath: '../'}))
      },
      // all css required in src/app files will be merged in js files
      {test: /\.scss$/, exclude: helpers.root('src', 'style'), loader: 'raw-loader!postcss-loader!sass-loader'},

      // support for .html as raw text
      // todo: change the loader to something that adds a hash to images
      {test: /\.html$/, loader: 'raw-loader'}

    ],


    noParse: [/.+zone\.js\/dist\/.+/, /.+angular2\/bundles\/.+/, /angular2-polyfills\.js/,
      /.+@angular\/animations\/bundles\/.+/,
      /.+@angular\/common\/bundles\/.+/,
      /.+@angular\/compiler\/bundles\/.+/,
      /.+@angular\/compiler-cli\/bundles\/.+/,
      /.+@angular\/core\/bundles\/.+/,
      /.+@angular\/forms\/bundles\/.+/,
      /.+@angular\/http\/bundles\/.+/,
      /.+@angular\/platform-browser\/bundles\/.+/,
      /.+@angular\/platform-browser-dynamic\/bundles\/.+/,
      /.+@angular\/platform-server\/bundles\/.+/,
      /.+@angular\/router\/bundles\/.+/,
      /.+pdfjs-dist\/build\/.+/,
      /.+jspdf\/dist\/.+/,
      /.+moment\/.+/,
      /.+socket-io-client\/dist\/.+/,
      /.+rxjs\/bundles\/.+/]

  },

  // Add additional plugins to the compiler.
  //
  // See: http://webpack.github.io/docs/configuration.html#plugins
  plugins: ( function() {

    var plugins = [];

    plugins.push(
      // Generate common chunks if necessary
      // Reference: https://webpack.github.io/docs/code-splitting.html
      // Reference: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
      new CommonsChunkPlugin({
        name: ['vendor', 'polyfills', 'environment']
      })
    );

       // Tslint configuration for webpack 2
    plugins.push(new webpack.LoaderOptionsPlugin({
      options: {
        resolve: {
          extensions: ['.ts', '.tsx', '.js']
        },
        /**
         * Apply the tslint loader as pre/postLoader
         * Reference: https://github.com/wbuchwalter/tslint-loader
         */
        ts : {
          'ignoreDiagnostics': [
            2403, // 2403 -> Subsequent variable declarations
            2300, // 2300 -> Duplicate identifier
            2374, // 2374 -> Duplicate number index signature
            2375, // 2375 -> Duplicate string index signature
            2502  // 2502 -> Referenced directly or indirectly
          ]
        },
        /*tslint: {
          emitErrors: false,
          failOnHint: false
        },*/
        /**
         * Sass
         * Reference: https://github.com/jtangelder/sass-loader
         * Transforms .scss files to .css
         */
        sassLoader: {
          //includePaths: [path.resolve(__dirname, "node_modules/foundation-sites/scss")]
        },
        /**
         * PostCSS
         * Reference: https://github.com/postcss/autoprefixer-core
         * Add vendor prefixes to your css
         */
        postcss: [
          autoprefixer({
            browsers: ['last 2 version']
          })
        ]
      }
    }));

    plugins.push(
      // Adding Moment
      new webpack.ProvidePlugin({
        moment: 'moment'
      })
    );

    plugins.push(
      // Adding Moment
      new webpack.ProvidePlugin({
        'file-saver': 'file-saver'
      })
    );

    plugins.push(
      // Adding Moment
      new webpack.ProvidePlugin({
        'pdf-designer': 'pdf-designer'
      })
    );

    plugins.push(
      // Adding jspdf
      new webpack.ProvidePlugin({
        'jspdf': 'jspdf'
      })
    );

    plugins.push(
      // Adding uuid-random
      new webpack.ProvidePlugin({
        'socket.io-client': 'socket.io-client'
      })
    );

    plugins.push(
      // Adding uuid-random
      new webpack.ProvidePlugin({
        'uuid-random': 'uuid-random'
      })
    );

    plugins.push(
      new webpack.DefinePlugin({
        'process.env': {
          'NODE_ENV': JSON.stringify('dev')
        }
      })
    );

    plugins.push(
      // Adding uuid-random
      new webpack.ProvidePlugin({
        'xlsx': 'xlsx'
      })
    );

    plugins.push(
      // Inject script and link tags into html files
      // Reference: https://github.com/ampedandwired/html-webpack-plugin
      new HtmlWebpackPlugin({
        template: './src/public/index.html',
        inject: 'body',
        chunksSortMode: 'dependency',
        cache: true
      })
    );

    plugins.push(
      // Extract css files
      // Reference: https://github.com/webpack/extract-text-webpack-plugin
      // Disabled when in test mode or not in build mode
      new ExtractTextPlugin('css/[name].css', {
        disable: true
      })
    );

    plugins.push(
      // Copy assets from the public folder
      // Reference: https://github.com/kevlened/copy-webpack-plugin
      new CopyWebpackPlugin([{
        from: helpers.root('config/environment.dev.js'),
        to: './environment.js'
      }])
    );

    plugins.push(
      // Copy assets from the public folder
      // Reference: https://github.com/kevlened/copy-webpack-plugin
      new HardSourceWebpackPlugin()
    );

    return plugins;

  }()),

  // Webpack Development Server configuration
  // Description: The webpack-dev-server is a little node.js Express server.
  // The server emits information about the compilation state to the client,
  // which reacts to those events.
  //
  // See: https://webpack.github.io/docs/webpack-dev-server.html
  devServer: {
    host: BRANCH_GUI_PROPERTIES.host,
    port: parseInt(BRANCH_GUI_PROPERTIES.port),
    inline: true,
    contentBase: './src/public',
    historyApiFallback: true,
    //stats: 'minimal' // none (or false), errors-only, minimal, normal (or true) and verbose
    stats: {
      colors: true,
      hash: false,
      version: false,
      timings: true,
      assets: false,
      chunks: false,
      modules: false,
      reasons: false,
      children: false,
      source: false,
      errors: true,
      errorDetails: false,
      warnings: false,
      publicPath: false
    }
  }
};

I cannot get your plugin stats with a npm run build or npm run start:hmr (webpack-dev-server).

Any idea what I'm missing?
Thanks in advance!

Worker error Error: No code sections found

at Bundle.validate (/home/sven/projects/devRantron/node_modules/inspectpack/lib/models/bundle.js:54:11)
at createBundle (/home/sven/projects/devRantron/node_modules/inspectpack/lib/models/bundle.js:262:12)
at Immediate.setImmediate (/home/sven/projects/devRantron/node_modules/inspectpack/lib/models/bundle.js:313:7)
at runCallback (timers.js:763:18)
at tryOnImmediate (timers.js:734:5)
at processImmediate (timers.js:716:5)

I get this output around 7-10 times each build.

webpack: 4.5.0
webpack-cli: 2.0.14
plugin: 1.2.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.