forked from lovefishs/react-router-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
60 lines (59 loc) · 1.71 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
const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: resolve(__dirname, './src/main.jsx'),
output: {
path: resolve(__dirname, './dist'),
filename: 'bundle.js',
chunkFilename: 'chunk.[name].js',
publicPath: '',
},
resolve: {
mainFields: ['browser', 'jsnext:main', 'module', 'main'],
extensions: ['.js', '.jsx', '.json'],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: [
{
loader: 'babel-loader',
options: {
presets: [['env', { modules: false }], 'react'],
// 装饰器插件的位置顺序非常重要,see: https://github.com/mobxjs/mobx/issues/105
plugins: ['transform-decorators-legacy', 'transform-decorators', 'syntax-dynamic-import', 'transform-class-properties', 'transform-runtime'],
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: resolve(__dirname, './src/index.html'),
minify: {
collapseWhitespace: true,
removeComments: true,
},
inject: 'body', // true | 'head' | 'body' | false
// chunks: [],
}),
],
devServer: {
host: '0.0.0.0',
port: 3000,
inline: false, // true 会启用 inline mode,一段处理实时重载的脚本被插入到 bundle 中(页面会自动刷新)
hot: false, // 推荐与 inline: true 一起配置
contentBase: resolve(__dirname, './dist'),
publicPath: '',
compress: true,
noInfo: false,
overlay: true,
clientLogLevel: 'none',
stats: 'minimal',
headers: {},
},
}