-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.client.js
47 lines (43 loc) · 1.1 KB
/
webpack.config.client.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
const path = require('path')
const HTMLPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const webpackMerge = require('webpack-merge')
const baseConfig = require('./webpack.base')
const isDev = process.env.NODE_ENV === 'development'
const config = webpackMerge(baseConfig, {
entry: {
app: path.join(__dirname, '../client/app.js')
},
output: {
filename: '[name].[hash].js',
},
mode: 'development',
plugins: [
new HTMLPlugin({
template: path.join(__dirname, '../client/template.html')
})
]
})
if (isDev) {
config.entry = {
app: [
'react-hot-loader/patch',
path.join(__dirname, '../client/app.js')
]
}
config.devServer = {
host: '0.0.0.0',
port: '8888',
contentBase: path.join(__dirname, '../dist'),
hot: true,
overlay: {
errors: true
},
publicPath: '/public/', // html中路径无法找到,需要配置
historyApiFallback: {
index: '/public/index.html' // 所有404的请求返回这段html
}
}
config.plugins.push(new webpack.HotModuleReplacementPlugin)
}
module.exports = config