webpack-encore icon indicating copy to clipboard operation
webpack-encore copied to clipboard

Possible Build Optimizations

Open weaverryan opened this issue 7 years ago • 7 comments

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 :)

weaverryan avatar Jan 25 '18 14:01 weaverryan

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)

Lyrkan avatar Jan 26 '18 08:01 Lyrkan

I think that's probably wise :)

weaverryan avatar Feb 11 '18 01:02 weaverryan

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.

seyfer avatar Jan 14 '19 11:01 seyfer

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.

seyfer avatar Jan 14 '19 13:01 seyfer

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.

claytron5000 avatar Nov 09 '20 14:11 claytron5000

I want to second supporting Dllplugin.

claytron5000 avatar Nov 09 '20 14:11 claytron5000

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot avatar Jan 09 '25 12:01 carsonbot

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot avatar Jul 10 '25 12:07 carsonbot

Friendly ping? Should this still be open? I will close if I don't hear anything.

carsonbot avatar Jul 24 '25 12:07 carsonbot

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!

carsonbot avatar Aug 07 '25 12:08 carsonbot