WebDevStudios / wds-block-starter

A block starter for projects.
15 stars 3 forks source link

Webpack 5 splitChunks Update #8

Closed michealengland closed 4 years ago

michealengland commented 4 years ago

Related To https://github.com/WebDevStudios/wds-block-starter/pulls

Once Webpack 5 is supported we should update our module.exports to use splitChunks to extract styles into CSS files after verifying this feature works as expected. This will improve performance and simplify code. Also, this is the recommended way from mini-css-extract-plugin.

Example code to add ( may need modified ).

    optimization: {
        namedChunks: true,
        namedModules: true,
        splitChunks: {
            cacheGroups: {
                styles: {
                    name: 'style',
                    test: /style\.(sa|sc|c)ss$/,
                    chunks: 'all',
                    enforce: true,
                },
                editor: {
                    name: 'editor',
                    test: /editor\.(sa|sc|c)ss$/,
                    chunks: 'all',
                    enforce: true,
                },
            },
        },
    },
michealengland commented 4 years ago

This issue is no longer necessary with updates provided by WP Scripts 12. WP Scripts will manage the handling of imported scss assets.

See https://github.com/WebDevStudios/wds-block-starter/pull/35