symfony / webpack-encore

A simple but powerful API for processing & compiling assets built around Webpack
https://symfony.com/doc/current/frontend.html
MIT License
2.23k stars 198 forks source link

Possible Build Optimizations #249

Open weaverryan opened 6 years ago

weaverryan commented 6 years ago

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

Lyrkan commented 6 years ago

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:

weaverryan commented 6 years ago

I think that's probably wise :)

seyfer commented 5 years ago

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 commented 5 years ago

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.

claytron5000 commented 3 years ago

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 commented 3 years ago

I want to second supporting Dllplugin.