I recently switched from browserify to webpack and the build time jumped from 4s to 16s on (2014 MBP). I understand webpack does alot more than browserify but i shouldn't take that long. My build process is fairly simple. Are there any tips or options to improve my build time?
var webpackOptions = { cache : true, output: { filename: '[name].js', }, module: { loaders: [ { test: /\.js$/, loader: 'jsx-loader' }, { test: /\.css$/, loader: "style!css" } ] }, }; gulp.task('buildJs', function(){ multipipe( gulp.src(jsSrcPath), named(), webpack(webpackOptions), uglify(), gulp.dest(jsDestPath) ).on('error', function(error){ console.log(error) }); });
Over the past eight years, webpack has become increasingly powerful. However, due to the additional packaging process, the building speed is getting slower as the project grows. As a result, each startup takes dozens of seconds (or minutes), followed by a round of build optimization.
Tells webpack to determine and flag chunks which are subsets of other chunks in a way that subsets don't have to be loaded when the bigger chunk has been already loaded. By default optimization. flagIncludedChunks is enabled in production mode and disabled elsewise. webpack.config.js module.
We use babel and TailwindCSS. Using simple methods, I discovered that CSS and JS take about the same time to build. Benchmark: Webpack build took 64 seconds, whole build took 91 seconds.
You should set include
paths for your loaders. Example:
{ test: /\.js$/, loader: 'jsx-loader', include: jsSrcPath }
Consider doing the same for that css case.
In my experience this can give massive gains as it doesn't have to traverse through node_modules
anymore. Alternatively you could exclude
node_modules
but I find it neater just to set up that include
. It gets more complicated if you are requiring content out of the include path, though.
Docs for include/exclude
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With