Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AbirkulovSherali's avatar

MiniCssExtractPlugin doesn't compile scss files into css files

Hi. I don't understand the behave of MiniCssExtractPlugin. I have style folder where .scss files are placed. But when I run webpack no css files appear in dist folder. May be I do something wrong. If somebody knows how to make it right, tell me. Thank you in advance )

Here is a webpack.config.js file

const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const NODE_ENV = process.env.NODE_ENV;
const devMode = NODE_ENV !== 'production';

module.exports = {
    cache: false,
    mode: NODE_ENV,
    entry: './src/js/main.js',
    output: {
        path: __dirname + '/dist',
            filename: "bundle.js"
    },

    resolve: {
        alias: {
            "bxslider": 'bxslider/dist/jquery.bxslider.js'
        }
    },

    module: {
        rules: [
            {
                test: /\.scss$/,
                use: [
                    MiniCssExtractPlugin.loader
                    'css-loader',
                    'sass-loader'
                ]
            },
            {
                test: /\.(jpg|jpeg|png|svg)$/,
                use: [{
                    loader: 'file-loader',
                    options: {
                        name: '[name].[ext]',
                        outputPath: 'img/',
                        publicPath: '/dist/img/'
                    }
                }]
            },
            {
                test: /\.(o|t)tf$/,
                use: [{
                    loader: 'file-loader',
                    options: {
                        name: '[name].[ext]',
                        outputPath: 'fonts/',
                        publicPath: '/dist/fonts/'
                    }
                }]
            }
        ]
    },

    plugins: [
        new MiniCssExtractPlugin({
            filename: 'main.css'
        })
    ],

    devtool: 'source-map'
}

0 likes
0 replies

Please or to participate in this conversation.