-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
58 lines (51 loc) · 1.51 KB
/
webpack.config.js
File metadata and controls
58 lines (51 loc) · 1.51 KB
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
var webpack = require('webpack');
var path = require('path');
module.exports = {
// source-map 配置
devtool: 'cheap-module-eval-source-map',
// 编译文件入口
entry: {
app: [
'webpack-dev-server/client?http://localhost:8090',
'webpack/hot/only-dev-server',
'./src/index.js'
],
// 对应CommonsChunkPlugin的vendors
vendors: ['react', 'react-dom', 'react-redux', 'redux', 'react-router']
},
// 输出目录及文件
output: {
filename: 'bundle.js',
path: path.join(__dirname, 'dist'),
publicPath: '/dist/'
},
resolve: {
//利用别名做重定向
alias: {
styles: path.resolve(__dirname, 'styles')
}
},
module: {
loaders: [
// babel-loader babel-preset-react babel-preset-es2015
{
test: /\.js[x]?$/,
include: path.join(__dirname, 'src'),
loaders: ['react-hot', 'babel-loader']
},
// css-loader
//{ test: /\.css$/, loader: 'style-loader!css-loader?modules' },
{
test: /\.css?$/,
loaders: ['style', 'raw'],
include: __dirname
}
]
},
plugins: [
// 减少文件大小
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.bundle.js'),
new webpack.HotModuleReplacementPlugin()
]
}