forked from samonxian/end
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
70 lines (69 loc) · 2.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
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
var webpack = require('webpack')
var path = require('path')
var uglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
/**
* 开发环境开react热替换
*/
var entry,leb;
var NODE_ENV = 'development';
//entry = ['webpack-dev-server/client?http://localhost:8000','webpack/hot/only-dev-server','./src/index.jsx'];
entry = [
'eventsource-polyfill', // necessary for hot reloading with IE
'webpack-hot-middleware/client',
'./src/index.jsx'
]
module.exports = {
devtool: 'inline-source-map',
entry: {
app : entry,
libs : ['react','antd'],
},
output: {
publicPath: '/js/',
path: __dirname + '/public/js/',
filename: 'bundle.js',
libraryTarget: "umd",
chunkFilename: '[name].chunk.js?random='+new Date().getTime()
},
module: {
loaders: [
{ test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=50000&name=[path][name].[ext]'},
{
test: /\.js[x]?$/,
loader: 'babel',
exclude: /node_modules/,//解析node_modules的es6语法
},
{ test: /\.css$/, loader: "style!css" },
]
},
resolve: {
alias: {
'.fr': __dirname + '/.fr/',
'r2': path.resolve(__dirname,'src/libs/r2'),
'frontend': __dirname + '/.fr/generator/frontend',
'css': __dirname + '/style/css/',
'img': __dirname + '/style/img/',
'src': __dirname + '/src/',
'page': __dirname + '/src/page/',
'libs': __dirname + '/src/libs/',
'JSONP': __dirname + '/src/libs/jsonp.js',
'function': __dirname + '/src/libs/function.js',
'validate': path.resolve(__dirname,'src/libs/antd-form-validate'),
'common': __dirname + '/src/libs/temp',
},
extensions: ['', '.js', '.jsx']
},
externals : [
{
}
],
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin("vendor","vendor.bundle.js",['app']),
new webpack.optimize.CommonsChunkPlugin("libs","libs.bundle.js",['vendor','chunk']),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV) //定义开发和生产环境
}),
]
};