Skip to content

How to generate separate css files based on entries from sass? #164

@rootical

Description

@rootical

Dear all,

Could you please help to understand how can I generate separate files based on entry?

My config is:

module.exports = {
    mode: 'production',
    entry: ['src/one.scss', 'src/two.scss'],
    output: {
        path: path.resolve(__dirname, '.temp')
    },
    plugins: [
        new MiniCssExtractPlugin({
            // Options similar to the same options in webpackOptions.output
            // both options are optional
            filename: '[name].[hash].css'
        })
    ],
    module: {
        rules: [
            {
                test: /\.s?[ac]ss$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    {
                        loader: 'postcss-loader',
                        options: {
                            plugins: () => [require('autoprefixer')],
                        },
                    },
                    {
                        loader: 'sass-loader',
                        options: {
                            includePaths: [
                                './src'
                            ]
                        }
                    }
                ]
            }
        ]
    }
};

So basically I just want to endup with two css files laying under .temp folder: one.css and two.css.

I tried to use based on entry option from the docs but it doesn't seem to work in my case.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions