-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
113 lines (95 loc) · 3.3 KB
/
webpack.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
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
const common = require('./webpack.common.js');
const package = require('./package.json');
const { merge } = require('webpack-merge');
var ZipPlugin = require('zip-webpack-plugin');
const GenerateJsonPlugin = require("generate-json-webpack-plugin")
delete package.scripts;
delete package.devDependencies;
delete package.dependencies;
delete package.peerDependencies;
delete package.peerDependenciesMeta;
delete package.peerDependenciesMeta;
delete package.optionalDependencies;
delete package.bundledDependencies;
delete package.resolutions;
delete package.engines;
delete package.private;
delete package.publishConfig;
module.exports = merge(common, {
mode: 'production',
/**
* Plugins
* Reference: http://webpack.github.io/docs/configuration.html#plugins
* List: http://webpack.github.io/docs/list-of-plugins.html
*/
plugins: [
// // Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin
// // Only emit files when there are no errors
//// new webpack.NoErrorsPlugin(),
//
// // Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
// // Minify all javascript, switch loaders to minimizing mode
//// new webpack.optimize.UglifyJsPlugin(),
// Copy assets from the public folder
// Reference: https://github.com/kevlened/copy-webpack-plugin
// new CopyPlugin([{
// from: __dirname + '/src/public'
// }])
new GenerateJsonPlugin('spa.json', package),
new ZipPlugin({
// OPTIONAL: defaults to the Webpack output path (above)
// can be relative (to Webpack output path) or absolute
// path: '.',
// OPTIONAL: defaults to the Webpack output filename (above) or,
// if not present, the basename of the path
filename: 'vw-dashboard.zip',
// OPTIONAL: defaults to 'zip'
// the file extension to use instead of 'zip'
extension: 'zip',
// OPTIONAL: defaults to the empty string
// the prefix for the files included in the zip file
// pathPrefix: 'relative/path',
// OPTIONAL: defaults to the identity function
// a function mapping asset paths to new paths
// pathMapper: function(assetPath) {
// // put all pngs in an `images` subdir
// if (assetPath.endsWith('.png'))
// return path.join(path.dirname(assetPath), 'images', path.basename(assetPath));
// return assetPath;
// },
// OPTIONAL: defaults to including everything
// can be a string, a RegExp, or an array of strings and RegExps
// include: [/\.js$/],
// OPTIONAL: defaults to excluding nothing
// can be a string, a RegExp, or an array of strings and RegExps
// if a file matches both include and exclude, exclude takes precedence
// exclude: [/\.png$/, /\.html$/],
// yazl Options
// OPTIONAL: see https://github.com/thejoshwolfe/yazl#addfilerealpath-metadatapath-options
fileOptions: {
mtime: new Date(),
mode: 0o100664,
compress: true,
},
// OPTIONAL: see https://github.com/thejoshwolfe/yazl#endoptions-finalsizecallback
zipOptions: {
forceZip64Format: false,
},
})
],
/*
* Optimize the output code
*/
optimization: {
splitChunks: {
chunks: 'all',
// maxSize: 244*1024
},
},
/**
* Devtool
* Reference: http://webpack.github.io/docs/configuration.html#devtool
* Type of sourcemap to use per build type
*/
devtool: 'source-map',
});