Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
114 lines (103 loc) · 3.26 KB
/
Copy pathwebpack.config.js
File metadata and controls
114 lines (103 loc) · 3.26 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var path = require('path');
var webpack = require('webpack');
var args = require('node-args');
var config = {
entry: {
build: './View/index.js'
},
output: {
path: path.join(__dirname, '/Lib'),
publicPath: '/Lib/',
filename: '[name].js'
},
plugins: [
// new webpack.optimize.CommonsChunkPlugin('antd', 'antd.js')
],
devServer: {
proxy: {
/*
* proxy配置例子
*
* '/some/*': {
* target: 'http://cdn.staticfile.org/',
* ignorePath: true, //忽略请求的路径,直接转发target的内容
* changeOrigin: true, //更改请求的域名(服务器)
* secure: false, //是否校验ssl证书
* rewrite: function(req) {
* req.url = req.url.replace(/^\/some/, '');
* }
* },
*/
//业务数据接口
'/api/*': {
target: 'http://pdms3.cx.test.yunshanmeicai.com/',
changeOrigin: true,
},
},
// 配置hosts 127.0.0.1 local.test.yunshanmeicai.com
//本地开发时,兼容HTML5 history API(可以在任意路径下刷新,返回index.html的内容加载React应用)
//参考:http://webpack.github.io/docs/webpack-dev-server.html#the-historyapifallback-option
historyApiFallback: true,
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel?presets[]=react,presets[]=es2015"
}, {
test: /\.jsx$/,
exclude: /node_modules/,
loader: "babel-loader"
}, {
test: /\.less$/,
exclude: /node_modules/,
loader: "style-loader!css-loader!less-loader"
}, {
test: /\.css$/,
exclude: /node_modules/,
loader: "style-loader!css-loader"
}, {
test: /\.png$/,
exclude: /node_modules/,
loader: "url-loader"
}, {
test: /\.json$/,
loader: "json-loader"
}, {
test: /\.(eot|woff|woff2|ttf|svg)$/,
loader: "file-loader"
}, {
test: /\.md$/,
loader: 'bisheng/lib/loaders/markdown-loader'
}]
},
}
// {
// test : /\.woff|\.woff2|\.svg|.eot|\.ttf/,
// loader : 'url?prefix=font/&limit=10000'
// }
//用webpack自带的-d组合项代替
//if (args.minify) {
// config.plugins = [
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: true
// }
// }),
// new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.DefinePlugin({
// 'process.env.NODE_ENV': '"production"' //production
// }),
// // new webpack.HotModuleReplacementPlugin(),
// // new webpack.optimize.CommonsChunkPlugin('antd', 'antd.js')
// ];
//}
//如果是-p生产环境的build,设置NODE_ENV
if (args.p) {
config.plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"' //production
}),
];
}
module.exports = config;