This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
83 lines (70 loc) · 2.18 KB
/
webpack.config.prod.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
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;
var extractCSS = new ExtractTextPlugin('styles/[name]-[chunkhash].css');
var CleanWebpackPlugin = require('clean-webpack-plugin');
// Import common webpack config
var config = require('./webpack.config.base.js');
// dis url
var dist = path.resolve(__dirname, "/dist");
// Devtool
config.devtool = 'cheap-module-source-map';
// Extract css to a seprate file
config.module.loaders[1] = {
test: /\.sss$/,
loader: extractCSS.extract('style', 'css?sourceMap!postcss?parser=sugarss')
};
config.module.loaders[2] = {
test: /\.css$/,
loader: extractCSS.extract('style', 'css?sourceMap!postcss')
};
config.output.filename = "[name]-[hash].js";
config.output.chunkFilename = "[name]-[chunkhash].js";
config.output.publicPath = '/dist/';
// --
// config.externals = {
// "react": "React",
// },
// Optimize for production
config.plugins = config.plugins.concat([
extractCSS,
// new webpack.optimize.CommonsChunkPlugin('common.js'),
new webpack.DefinePlugin({
'__BROWSER__': true,
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
// ignore dev config
new webpack.IgnorePlugin(/\.\/dev/, /\/config$/, /react/),
// new webpack.ProvidePlugin({
// React: "React", react: "React", "window.react": "React", "window.React": "React"
// })
// Write out stats.json file to build directory.
new StatsWriterPlugin({
filename: "stats.json", // Default
transform: function (data) {
return JSON.stringify({
main: data.assetsByChunkName.main[0],
css: data.assetsByChunkName.main[1]
}, null, 2);
}
}),
// Clean up
new CleanWebpackPlugin(['dist'], {
root: '/Users/mohammad/Documents/htdocs/tarino/panel/',
verbose: true,
dry: false,
// exclude: ['shared.js']
})
]);
module.exports = config;