-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathwebpack.config.js
More file actions
66 lines (64 loc) · 1.55 KB
/
webpack.config.js
File metadata and controls
66 lines (64 loc) · 1.55 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
59
60
61
62
63
64
65
66
var path = require('path');
var webpack = require('webpack');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'app');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');
var TEM_PATH = path.resolve(ROOT_PATH, 'templates');
module.exports = {
entry:{
app:path.resolve(APP_PATH,'index.jsx')
},
output:{
path:BUILD_PATH,
filename:'[name].js'
},
resolve:{
extensions:['.js','.jsx']
},
//启动dev source map,出错以后就会采用source-map的形式直接显示你出错代码的位置。
devtool:'eval-source-map',
devServer:{
historyApiFallback:true,
hot:true,
inline:true,
proxy:{
'/api/*':{
target:'http://localhost:8080',
secure:false
}
}
},
module:{
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
include: APP_PATH,
query: {
//添加两个presents 使用这两种presets处理js或者jsx文件
presets: ['es2015', 'react']
}
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.css$/,
loaders: ['style', 'css', 'sass']
}
]
},
plugins: [
//这个使用uglifyJs压缩你的js代码
new webpack.optimize.UglifyJsPlugin({minimize: true}),
new HtmlwebpackPlugin({
title: 'react-ele-webapp',
template: path.resolve(TEM_PATH, 'index.html'),
filename: 'index.html',
chunks: ['app', 'vendors'],
inject: 'body'
})
]
}