-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.production.config.js
More file actions
101 lines (99 loc) · 2.79 KB
/
webpack.production.config.js
File metadata and controls
101 lines (99 loc) · 2.79 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
'use strict';
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var InlineManifestWebpackPlugin = require('inline-manifest-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var clean = require('clean-webpack-plugin');
module.exports = {
entry: {
browser: path.join(__dirname, 'app/App.js'),
ieCompatible: path.join(__dirname, 'app/utils/ie-compatible.js'),
mobile: path.join(__dirname, 'app/App-h5.js'),
common: ['react', 'react-router']
},
output: {
path: path.join(__dirname, '/dist/'),
filename: '[name]-[chunkhash].min.js'
},
resolve: {
modulesDirectories: ['node_modules'],
},
plugins: [
new clean(['dist']),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
filename: 'common-[chunkhash].min.js',
chunks: ['browser', 'mobile']
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
filename: 'manifest-[chunkhash].min.js',
chunks: ['common']
}),
new HtmlWebpackPlugin({
inject: false,
template: 'app/index.html',
filename: 'index.html',
chunks: ['common', 'browser', 'ieCompatible'],
chunksSortMode: function(chunk1, chunk2){
return chunk1.id - chunk2.id;
},
minify: {
collapseWhitespace: true,
processConditionalComments: true
}
}),
new HtmlWebpackPlugin({
template: 'app/index-h5.html',
filename: 'index-h5.html',
chunks: ['common', 'mobile'],
chunksSortMode: function(chunk1, chunk2){
return chunk1.id - chunk2.id;
},
minify: {
collapseWhitespace: true
}
}),
new InlineManifestWebpackPlugin(),
new ExtractTextPlugin('[name]-[contenthash].min.css'),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
module: {
loaders: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel'
},{
test: /\.js?$/,
exclude: /[node_modules|lib]/,
loader: 'eslint'
}, {
test: /\.json?$/,
loader: 'json'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?modules&localIdentName=[name]---[local]---[hash:base64:5]!postcss')
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader')
}, {
test: /\.(woff(2)?|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}, {
test: /\.(png|jpg|jpeg|gif)$/,
loader: 'file-loader?name=i/[name].[ext]'
}]
},
postcss: [
require('autoprefixer')
]
};