-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
95 lines (92 loc) · 2.07 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const webpack = require('webpack');
const HtmlWebPackPlugin = require("html-webpack-plugin");
const publicPath = '/';
const config = {
entry: {
main: './src/entry.bs.js'
},
output: {
filename: 'static/js/[name].[chunkhash:8].js',
publicPath: publicPath,
},
module: {
rules: [
{
test: /\_worker\.bs\.js$/,
use: {
loader: 'worker-loader',
options: {
name: 'static/js/[hash].worker.js'
}
}
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: { minimize: true }
}
]
},
{
exclude: [ /\.js$/, /\.html$/, /\.json$/],
loader: require.resolve('file-loader'),
options: {
name: 'static/media/[name].[hash:8].[ext]',
}
}
]
},
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
mangle: true,
}
}),
],
},
plugins: [
new HtmlWebPackPlugin({
inject: true,
template: "./static/index.html",
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyURLs: true,
},
}),
],
devServer: {
https: true,
compress: true,
clientLogLevel: 'none',
port: 3000,
contentBase: './static',
publicPath: publicPath,
historyApiFallback: {
disableDotRule: true,
},
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization",
},
},
node: {
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
};
module.exports = config;