-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
52 lines (47 loc) · 1.19 KB
/
webpack.config.js
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
require('webpack');
const PATH = require('path');
const HTML_PLUGIN = require('html-webpack-plugin');
const MINI_CSS_EXTRACT_PLUGIN = require('mini-css-extract-plugin');
const HTML_INLINE_SOURCE_PLUGIN = require('html-webpack-inline-source-plugin');
const OPTIMIZE_CSS_ASSETS_PLUGIN = require('optimize-css-assets-webpack-plugin');
const IS_PRODUCTION = process.env.npm_lifecycle_event === 'build';
const APP_ENTRY = PATH.resolve('src', 'index.js');
let jsRule = {
test: /\.js$/,
use: ['babel-loader']
};
let cssRule = {
test: /\.css$/,
use: [
MINI_CSS_EXTRACT_PLUGIN.loader,
{
loader: 'css-loader'
}
]
};
const CONFIGURATION = {
entry: APP_ENTRY,
devtool: !IS_PRODUCTION && 'source-map',
module: {
rules: [jsRule, cssRule]
},
plugins: [
new HTML_PLUGIN({
template: 'src/index.html',
minify: IS_PRODUCTION && {
collapseWhitespace: true
},
inlineSource: IS_PRODUCTION && '.(js|css)$'
}),
new HTML_INLINE_SOURCE_PLUGIN(),
new OPTIMIZE_CSS_ASSETS_PLUGIN({}),
new MINI_CSS_EXTRACT_PLUGIN({
filename: '[name].css'
})
],
devServer: {
stats: 'minimal',
overlay: true
}
};
module.exports = CONFIGURATION;