-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
76 lines (74 loc) · 1.88 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
const { resolve } = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const BabelMinifyPlugin = require('babel-minify-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const { DIST_DIR, BABEL_MINIFY_PLUGIN_OPTIONS, devtool, output } = require('./webpack.common');
module.exports = {
entry: {
bundle: './src/js/main.js',
index: './src/index.html',
main: './src/css/main.css',
vendor: './src/css/vendor.css',
},
module: {
rules: [
{
test: /\.html$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
{
loader: 'extract-loader',
},
{
loader: 'html-loader',
options: {
attrs: false,
minimize: true,
conservativeCollapse: false,
keepClosingSlash: false,
},
},
],
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: {
loader: 'css-loader',
options: {
minimize: true,
sourceMap: Boolean(devtool),
},
},
}),
},
],
},
plugins: [
new ExtractTextPlugin('[name].css'),
new BabelMinifyPlugin({}, BABEL_MINIFY_PLUGIN_OPTIONS),
new WorkboxPlugin({
globDirectory: DIST_DIR,
globPatterns: ['index.html', 'bundle.js', '*.css'],
swSrc: resolve(__dirname, 'src/js/service-worker/sw.js'),
swDest: resolve(__dirname, DIST_DIR, 'sw.js'),
}),
new BrowserSyncPlugin({
port: 8080,
server: {
baseDir: DIST_DIR,
},
reloadDebounce: 500,
startPath: '/?disable-sw',
}),
],
devtool,
output,
};