-
Notifications
You must be signed in to change notification settings - Fork 27
/
webpack.production.config.js
94 lines (92 loc) · 2.34 KB
/
webpack.production.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
const webpack = require('webpack')
const ENV = process.env.NODE_ENV || 'development'
const HtmlwebpackPlugin = require('html-webpack-plugin')
const sourcePath = './src/'
const buildPath = './dist/'
module.exports = {
entry: {
bundle: sourcePath + 'entry/index.jsx'
},
output: {
path: buildPath,
filename: '[name].[hash:8].js',
chunkFilename: '[id].[chunkhash:8].js'
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel!eslint'
}, {
test: /\.less$/,
loader: 'style!css!less'
}, {
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.(png|jpg|jpeg|gif)(\?v=\d+\.\d+\.\d+)?$/i,
loader: 'url-loader?limit=10192'
}, {
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=application/font-woff'
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=application/font-woff'
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=application/octet-stream'
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file'
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&minetype=image/svg+xml'
}, {
test: /\.json$/,
loader: 'json'
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
imageWebpackLoader: {
progressive: true,
optimizationLevel: 7,
interlaced: false,
pngquant: {
quality: '65-90',
speed: 4
}
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
plugins: [
new HtmlwebpackPlugin({
title: '君君辅导-老师信息平台',
template: sourcePath + 'page.ejs',
minify: {
collapseWhitespace: true
}
}),
new webpack.DefinePlugin({
_DEV_: ENV !== 'production',
_DEBUG_: ENV === 'debug',
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
}),
new webpack.optimize.LimitChunkCountPlugin(),
new webpack.optimize.UglifyJsPlugin({
output: {
comments: false // remove all comments
},
compress: {
warnings: false
}
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.CommonsChunkPlugin('common.js')
]
}