-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (63 loc) · 1.62 KB
/
webpack.config.js
File metadata and controls
68 lines (63 loc) · 1.62 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const entryPath = path.join(__dirname, 'src/static/index.js');
const outputPath = path.join(__dirname, 'build');
const mode = process.env.npm_lifecycle_event === 'build' ? 'production' : 'development';
let modeSpecificPlugins;
if (mode === 'production') {
modeSpecificPlugins = [
new OptimizeCssAssetsPlugin({}),
];
} else {
modeSpecificPlugins = [];
}
module.exports = {
mode: mode,
entry: entryPath,
output: {
path: outputPath,
filename: 'static/js/[name].[chunkhash].js',
},
module: {
noParse: /\.elm$/,
rules: [
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: [{
loader: 'elm-webpack-loader',
options: {
verbose: true,
warn: true,
debug: mode !== 'production',
}
}]
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
],
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: 'static/css/[name].[chunkhash].css',
}),
new HtmlWebpackPlugin({
template: 'src/static/index.html',
filename: 'index.html',
inject: 'head',
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'defer',
}),
...modeSpecificPlugins,
]
}