aboutsummaryrefslogtreecommitdiff
path: root/webpack.config.js
blob: 08cad4cf8c4b230f41ede1ebeafc2897411bb06f (plain) (blame)
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 ESLintPlugin = require('eslint-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');

module.exports = (env, argv) => {
    const dev = argv.mode !== 'production';
    const config = {
        devtool: dev ? 'source-map' : false,
        entry: {
            'scripts': [
                __dirname + '/src/main/assets/scripts.js'
            ]
        },
        output: {
            path: __dirname + '/src/main/resources/static',
            filename: '[name].js'
        },
        module: {
            rules: [
                { test: /\.js$/, loader: 'babel-loader' }
            ]
        },
        plugins: [
            new ESLintPlugin({ files: 'src/main/assets', lintDirtyModulesOnly: true, failOnWarning: false, failOnError: true, fix: false }),
            new CopyPlugin({
                patterns: [{
                    from: __dirname + '/node_modules/evil-icons/assets/sprite.svg',
                    to: __dirname + '/src/main/resources/static/'
                }],
            }),
        ],
    };
    config.optimization = {
        minimize: !dev
    };
    return config;
};