portfolio / portfolio-webapp / config / frontend / webpack.config.dev.js
webpack.config.dev.js
Raw
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require('path');
const configGlobals = require('./webpack.config.globals');

module.exports = {
    entry: configGlobals.ENTRY_POINTS,
    output: {
        filename: configGlobals.JS_OUTPUT_FILENAME + '.js',
        path: path.resolve(__dirname, '../../static'),
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: configGlobals.CSS_OUTPUT_FILENAME + '.css',
        })
    ],
    mode: 'development',
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            },
            {
                test: /\.(sa|sc|c)ss$/,
                // Set loaders to transform files.
                // Applied last-to-first
                use: [
                    // All transformed CSS to single bundled file
                    {
                        loader: MiniCssExtractPlugin.loader
                    },
                    // Resolves url() and @imports inside CSS. Also, required for MiniCssExtractPlugin
                    {
                        loader: "css-loader",
                    },
                    // autoprefixer and minifying
                    {
                        loader: "postcss-loader",
                        options: {
                            postcssOptions: {},
                        },
                    },
                    // SASS -> CSS (run first)
                    {
                        loader: "sass-loader",
                        options: {
                            implementation: require("sass")
                        }
                    }
                ]
            }
        ],
    },
};