summaryrefslogtreecommitdiff
path: root/webpack.config.js
blob: 99bbe49778d68428694119795894d338a58a32f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const path = require('path');
const webpack = require('webpack');

module.exports = (env, argv) => {
    const commonConf = {
        module: {
            rules: [
                {
                    test: /\.js$/,
                    exclude: /node_modules/,
                    use: 'babel-loader',
                }, {
                    test: /\.css$/,
                    use: ['style-loader', 'css-loader'],
                },
            ],
        },
    };

    const devConf = {
        devServer: {
            port: 3000,
            contentBase: path.resolve(__dirname, './src'),
            hot: true,
            stats: 'minimal',
        },
        devtool: 'source-map',
        plugins: [new webpack.HotModuleReplacementPlugin()],
    };

    if (argv.mode === 'development') {
        return { ...commonConf, ...devConf };
    }

    return commonConf;
};