-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.build.config.js
130 lines (123 loc) · 3.55 KB
/
webpack.build.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
var path = require('path');
const webpack = require("webpack");
var precss = require('precss');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var Clean = require('clean-webpack-plugin');
module.exports = {
entry: {
build: path.resolve(__dirname, 'app/index.js'),
vendor: ['react', 'react-dom','react-router']
},
output: {
path: path.resolve(__dirname, 'public/assets'),
publicPath: 'assets/',
filename: '[name].[chunkhash:5].js',
},
externals: {
jquery: 'jQuery',
},
plugins: [
new Clean('./public/assets'),
new webpack.LoaderOptionsPlugin({
options: {
postcss: function(){
return [
require("autoprefixer")({
browsers: ['ie>=8','>1% in CN']
})
]
}
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
beautify: false,
minimize: true,
sourceMap: true,
exclude: [
/node_modules/
],
output: {
comments: false,
ascii_only: true
}
}),
new webpack.optimize.CommonsChunkPlugin({ names: ['vendor', 'manifest'],minChunks: Infinity }),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new HtmlWebpackPlugin({
template: 'public/template.html',
filename: '../index.html'
}
)
],
module: {
loaders: [{
test: /\.jsx?$/,
exclude: [/node_modules/],
loaders: [
'react-hot-loader', 'babel-loader'
],
}, {
test: /\.(png|jpg|gif)$/,
loader: 'url-loader' // 这里的 limit=8192 表示用 base64 编码 <= 8K 的图像
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}, {
test: /\.less$/,
loader: 'style-loader!css-loader!less-loader'
}],
rules: [
{
test: /\.jsx?$/,
exclude: [/node_modules/],
use: [
'babel-loader'
]
},
{
test: /\.(png|jpg|gif)$/,
use: [
'url-loader'
]
},
{
test: /\.css$/,
use: [
'style-loader','css-loader'
]
},
{
test: /\.less$/,
use: [
'style-loader','css-loader','less-loader',{
loader: 'postcss-loader',
options: {
plugins: function() {
return [
precss,autoprefixer
]
}
}
}
]
},
],
noParse: /node_modules\/(jquey|moment|chart\lodash\.js)/
},
resolve: {
modules: [
path.join(__dirname, "app"),
"node_modules"
],
extensions: [".js", ".css", ".less", ".jsx", ".json"]
},
devtool: 'eval',
}