forked from mmillet/mock-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
116 lines (98 loc) · 2.57 KB
/
webpack.dev.config.js
File metadata and controls
116 lines (98 loc) · 2.57 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
115
116
var path = require('path'),
webpack = require('webpack'),
autoprefixer = require('autoprefixer'),
precss = require('precss'),
pages = require('./pages.config');
var SRC_PATH = path.join(__dirname, './assets/src'),
DIST_PATH = path.join(__dirname, '../static');
var config = {
entry: pages.entry,
resolve: {
root: [SRC_PATH],
alias: {},
extensions: ['', '.less', '.css', '.js', '.json']
},
output: {
path: DIST_PATH,
publicPath: '',
filename: 'js/[name].js'
},
clearBeforeBuild: false,
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ['vendors', 'manifest'],
minChunks: Infinity
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
'__DEV__': true
})
].concat(pages.htmlWebpackPlugins),
module: {
noParse: [],
loaders: [
{test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel-loader']},
// less url import issue
// see:https://github.com/webpack/css-loader/issues/74
{
test: /\.less$/,
include: /src(\\|\/)(containers|components)/,
loader: 'style!' +
'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!' +
'postcss!' +
'less'
},
{
test: /\.less$/,
include: /src(\\|\/)layouts/,
loader: 'style!' +
'css!' +
'postcss!' +
'less'
},
// css
{
test: /\.css$/,
exclude: /src/,
loader: 'style!css'
},
{
test: /\.(png|jpg|gif)$/,
loader: 'url',
query: {
limit: 8192,
name: 'images/[name].[ext]'
}
},
{
test: /\.(eot|woff|woff2|ttf|svg)((\?|\#)[\?\#\w\d_-]+)?$/,
loader: 'url',
query: {
limit: 100,
name: 'fonts/[name].[ext]'
}
}
],
},
//Fix react-hot-loader issue, see https://github.com/gaearon/react-hot-loader/issues/417
// alias: {'react/lib/ReactMount': 'react-dom/lib/ReactMount'},
postcss: function () {
return {
defaults: [precss, autoprefixer],
cleaner: [autoprefixer({ browsers: ['last 4 versions'] })]
};
},
devServer: {
hot: true,
inline: true,
proxy: {
// 配置代理,开发环境下以 /api 开头的请求被代理到 target
'/~m/*': {
target: 'http://127.0.0.1:8081',
secure: false
}
}
}
};
console.log('initializing webpack development build....');
module.exports = config;