T
T
to_east2019-01-20 16:05:04
css
to_east, 2019-01-20 16:05:04

Question: style-loader in production mode?

Greetings Toaster Members!
What functions does this loader perform, if I understand correctly, it dynamically generates the style tag, loads styles into it and adds head to the end. Well, this is for development mode, but for production, if styles are taken out into a separate file, then this style-loader is completely unnecessary?
Here are the config fragments for such a scenario, if it is true of course:

'use strict';

const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const developmentConfig = {
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    {
                        loader: 'style-loader',
                        options: {
                            singleton: true
                        }
                    },
                    'css-loader',
                    // ...
                ]
            }
        ]
    },
};


const productionConfig = {
    plugins: [
        new MiniCssExtractPlugin({
            filename: '[name].css'
        })
    ],

    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    // ...
                ]
            }
        ]
    },
};
// ...

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