This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.proddev.js
139 lines (128 loc) · 3.45 KB
/
webpack.config.proddev.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
131
132
133
134
135
136
137
138
139
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;
var ProgressBarPlugin = require('progress-bar-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin');
var ManifestPlugin = require('webpack-manifest-plugin');
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
var WebpackMd5Hash = require('webpack-md5-hash');
var sassLoaders = [
'css-loader?minimize',
'autoprefixer-loader?browsers=last 2 version',
'sass-loader?sourceMap&outputStyle=expanded&' +
'includePaths[]=' +
(encodeURIComponent(path.resolve(process.cwd(), './node_modules')))
];
var cssLoaders = [
'css-loader',
'autoprefixer-loader?browsers=last 2 version'
];
const vendor = [
'react', 'react-dom'
];
var statsOptions = {
filename: "stats.json",
fields: null,
transform: function (data) {
data.modules.forEach(function (m) {
delete m.source;
});
delete data.children;
return JSON.stringify(data, null, 2);
}
};
module.exports = {
devtool: 'source-map',
entry: {
app: __dirname + '/client/index.js',
vendor: vendor
},
output: {
path: __dirname + '/dist/static/',
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
publicPath: '/'
},
resolve: {
extensions: ['', '.js', '.jsx', '.json', '.scss']
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(png|jpg|svg)$/,
loader: "url-loader?limit=10000&mimetype=image/svg+xml"
},
{
test: /\.(woff|ttf|png|gif|jpg|jpeg)$/,
loader: 'file-loader'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!')),
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', cssLoaders.join('!'))
},
{
test: /\.jsx*$/,
exclude: /node_modules/,
loader: 'babel'
}
]
},
plugins: [
new ProgressBarPlugin({
format: ' build [:bar] :percent (:elapsed seconds) :msg',
clear: false
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['app', 'vendor', 'manifest'],
// name: 'vendor',
minChunks: Infinity,
children: true,
async: true
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
'CLIENT': JSON.stringify('true')
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new ExtractTextPlugin('[name].[chunkhash].css', {disable: false, allChunks: true}),
new webpack.optimize.DedupePlugin(),
new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
mangle : true,
compress: {
drop_debugger: true,
warnings: false,
drop_console: true,
screw_ie8: true,
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true
},
comments: /^\**!|^ [0-9]+ $|@preserve|@license/
}),
new CompressionPlugin(),
new WebpackMd5Hash(),
new ManifestPlugin(),
new ChunkManifestPlugin({
filename: 'chunk-manifest.json',
manifestVariable: 'webpackManifest',
}),
new StatsWriterPlugin(statsOptions)
]
};