-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
executable file
·69 lines (61 loc) · 1.79 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
61
62
63
64
65
66
67
68
69
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var OpenBrowserPlugin = require('open-browser-webpack-plugin') //自动打开浏览器插件
process.env.NODE_ENV = 'development' // 这个要写 .babel env 坑!
module.exports = {
entry: ['webpack/hot/dev-server', path.resolve(__dirname, 'app/Router.js')],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js'
},
devServer: {
contentBase: './app',
port: 3000,
color: true,
inline: true,
hot: true,
historyApiFallback: true
},// progress 不起作用
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.(png|jpg|gif)$/,
loader: 'url-loader?limit=8192' // 这里的 limit=8192 表示用 base64 编码 <= 8K 的图像
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.less$/,
loader: 'style-loader!css-loader!less-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './app/index.html'
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify("development")
}
}),
new webpack.HotModuleReplacementPlugin(), //热加载插件
new OpenBrowserPlugin({ url: 'http://localhost:3000' })
]
}
// new webpack.optimize.CommonsChunkPlugin('vendors','js/vendors.js'),
// vendors:['react','react-dom','react-router','redux','react-redux'] //第三方库和框架
// new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// compressor: {
// warnings: false,
// },
// }),