-
Notifications
You must be signed in to change notification settings - Fork 34
/
webpack.config.js
56 lines (54 loc) · 1.36 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
var webpack = require('webpack')
module.exports = {
entry: [
'./public/assets/js/entry.js'
],
output: {
path: __dirname + '/public/assets/',
publicPath: "/public/assets/",
filename: 'bundle.js'
},
module: {
loaders: [
{
test:/\.js$/,
exclude:/node_modules/,
loader: 'babel',
query: {
presets: ['es2015','react'], // 这部分内容可以单独写成一个babelrc文件
"env": {
"development": {
"plugins": [
["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}]
}
]
]
}
}
}
},
{
test: /\.css$/,
loader: "style-loader!css-loader?modules"
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin()//热加载插件
],
resolve: {
extensions: ['', '.js', '.jsx']
// 这里可以使用alias配置项,可以显示的指定我们常用的一些库,避免webpack自己的查找
},
devServer: {
contentBase: "./public",//本地服务器所加载的页面所在的目录
colors: true,//终端中输出结果为彩色
historyApiFallback: true,//不跳转
inline: true//实时刷新
}
};