-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
45 lines (44 loc) · 1.06 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
var path = require('path')
var webpack = require('webpack')
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: [
'react-hot-loader/patch',
'webpack/hot/only-dev-server', //HRM更新时刷新整个页面,如果是only-dev-server是手动刷新
`${__dirname}/client/index.js`
],
output: {
filename: '[name].js',
path: path.join(__dirname, 'public'),
publicPath: '/'
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
rules: [
{
test: /\.jsx?$/,
loaders: ['babel-loader'],
include: [path.join(__dirname, 'client')]
},
{
test: /\.css$/,
include: [path.join(__dirname, 'client')],
use: ['style-loader', 'css-loader', 'postcss-loader']
}
]
},
plugins: [
// new webpack.HotModuleReplacementPlugin(), // 启用 HMR
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin()
],
devServer: {
hot: true,
inline: true,
host: 'localhost',
port: 3333,
contentBase: path.resolve(__dirname, 'public')
}
}