forked from duxianwei520/react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
74 lines (73 loc) · 1.9 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
70
71
72
73
74
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
const casProxy = require('./proxy');
module.exports = {
entry: {
js: './app/client.js',
vendor: [
'react', 'classnames', 'react-router', 'react-dom',
],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: './vendor.js',
},
resolve: {
extensions: ['', '.js', '.json'],
alias: {
components: __dirname + '/app/components',
actions: __dirname + '/app/actions',
api: __dirname + '/app/api',
reducers: __dirname + '/app/reducers',
utils: __dirname + '/app/utils',
constants: __dirname + '/app/constants',
controllers: __dirname + '/app/controllers',
},
},
module: {
loaders: [
{
test: /\.js[x]?$/,
exclude: /node_modules/,
loader: 'react-hot!babel',
}, {
test: /\.less$/,
loader: 'style!css!postcss!less',
}, {
test: /\.css/,
loader: 'style!css',
}, {
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192',
},
],
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
/*压缩优化代码开始 可以关掉*/
// new webpack.optimize.UglifyJsPlugin({minimize: true}),
/*压缩优化代码结束*/
new HtmlWebpackPlugin({
template: path.join(__dirname, 'app/index.html'),
}),
new OpenBrowserPlugin({
url: 'http://localhost:3000'
}),
],
devtool: 'source-map',
devServer: {
contentBase: './app/',
historyApiFallback: true,
hot: true,
proxy: casProxy(),
host: '0.0.0.0'
},
}