Skip to content

How can I combine multiple CSS files into one when using wp-scripts? #62966

Closed Answered by Hannnes1
Hannnes1 asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, I figured out something that works:

const defaultConfig = require('@wordpress/scripts/config/webpack.config');

const cleanedDefaultPlugins = defaultConfig.plugins.filter(
    (plugin) => {
        if (['RtlCssPlugin'].includes(plugin.constructor.name)) {
            return false;
        }
        return true;
    }
);

module.exports = {
    ...defaultConfig,
    plugins: [
        ...cleanedDefaultPlugins,
    ],
    optimization: {
        ...defaultConfig.optimization,
        splitChunks: {
            cacheGroups: {
                styles: {
                    name: "style",
                    type: "css/mini-extract",
                    chunks: "all",
                    e…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Hannnes1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant