Possible Build Optimizations
Totally just dropping this here until I have some more time to look at it, but Slack had a nice summary of build optimizations: https://slack.engineering/keep-webpack-fast-a-field-guide-for-better-build-performance-f56a5995e8f1
It may be possible that we can package some of these automatically for users :)
Hey Ryan,
Maybe we should wait for Webpack 4 (see #250) before starting to work on that, they seem to have included some of the optimizations described in this post in their default settings (such as the UglifyJS parallelization).
Also, some related issues:
- Using HappyPack (#65)
- Using the DllPlugin (#81)
- Changing the type of the generated source maps in dev mode (#214)
I think that's probably wise :)
Have somebody tried https://github.com/webpack-contrib/thread-loader?
I do not even know how to add it to babel loaders list. It is not in the options.
I also do not understand how to try https://github.com/trivago/parallel-webpack with Encore. Seems like currently, Encore run configs in parallel on a single CPU. Am I right? But parallel-webpack uses node workers farm and runs on N cores in parallel.
Have somebody tried https://github.com/webpack-contrib/thread-loader?
I do not even know how to add it to babel loaders list. It is not in the options.
This is a hariy hack, but this got it working for typescript files. Better yet would be to request a feature to allow pre-pending loaders.
const pack = Encore.getWebpackConfig();
pack.module.rules.forEach(rule => {
if (rule.test.test('.ts')) {
// this could be configured above, but this way all the threading config is in one place.
rule.use.forEach(loader => {
if (loader.loader === 'ts-loader') {
loader.options.happyPackMode = true;
}
})
rule.use.unshift({loader: 'thread-loader', options: {
workers: 2
}})
}
})
I made a feature request to allow pre-pending loaders: https://github.com/symfony/webpack-encore/issues/852 NOTE: this is unrelated to this issue thread.
I want to second supporting Dllplugin.
Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?
Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?
Friendly ping? Should this still be open? I will close if I don't hear anything.
Hey,
I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!