A
A
Anton Antonov2018-08-18 23:54:53
JavaScript
Anton Antonov, 2018-08-18 23:54:53

How to setup mini-css-extract-plugin in webpack 4?

how to configure scss so that it would be going into one bundle ??
my code, js works, css doesn't..
const path = require('path');
let isDevMode = 'production' !== process.env.NODE_ENV;

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main.js',
    publicPath: 'dist/'
  },
  devServer: {
    overlay: true
  },
  module: {
        rules: [
            {
                test: /\.js$/,
                exclude: [/node_modules/],
                use: [
                    {
                        loader: 'babel-loader',
                        options: { presets: ['es2015'] }
                    }
                ]
            },
            {
                test: /\.css/,
                exclude: /node_modules/,
                use: [isDevMode ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader']
            }
       
        ]
    }, 
    plugins: isDevMode ? [] : [new MiniCssExtractPlugin({ filename: '[name].css' })]
};

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question