-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
57 lines (52 loc) · 1.37 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
var webpack = require('webpack');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js');
var port = "8081";
module.exports = {
//页面入口文件配置
entry: [
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:' + port,
'./src/pages/hello-world/index.jsx'
],
//入口文件输出配置
output: {
path: 'dist',
filename: 'bundle.js'
},
module: {
//加载器配置
loaders: [
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
},
//其它解决方案配置
resolve: {
},
devServer: {
contentBase: './dist',
color: true,
port: port
},
//插件项
plugins: [
commonsPlugin,
new HtmlwebpackPlugin({
filename: 'index.html',
template: 'src/pages/hello-world/index.html',
inject: false
}),
new OpenBrowserPlugin({
url: 'http://localhost:' + port
})
]
};