aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/config/webpack.prod.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/config/webpack.prod.js')
-rw-r--r--client/config/webpack.prod.js346
1 files changed, 174 insertions, 172 deletions
diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js
index 2db41d398..46db54482 100644
--- a/client/config/webpack.prod.js
+++ b/client/config/webpack.prod.js
@@ -30,201 +30,203 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
30 HMR: false 30 HMR: false
31}) 31})
32 32
33module.exports = webpackMerge(commonConfig, { 33module.exports = function (env) {
34 /** 34 return webpackMerge(commonConfig({env: ENV}), {
35 * Switch loaders to debug mode.
36 *
37 * See: http://webpack.github.io/docs/configuration.html#debug
38 */
39 debug: false,
40
41 /**
42 * Developer tool to enhance debugging
43 *
44 * See: http://webpack.github.io/docs/configuration.html#devtool
45 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
46 */
47 devtool: 'source-map',
48
49 /**
50 * Options affecting the output of the compilation.
51 *
52 * See: http://webpack.github.io/docs/configuration.html#output
53 */
54 output: {
55 /** 35 /**
56 * The output directory as absolute path (required). 36 * Switch loaders to debug mode.
57 * 37 *
58 * See: http://webpack.github.io/docs/configuration.html#output-path 38 * See: http://webpack.github.io/docs/configuration.html#debug
59 */ 39 */
60 path: helpers.root('dist'), 40 debug: false,
61 41
62 /** 42 /**
63 * Specifies the name of each output file on disk. 43 * Developer tool to enhance debugging
64 * IMPORTANT: You must not specify an absolute path here!
65 * 44 *
66 * See: http://webpack.github.io/docs/configuration.html#output-filename 45 * See: http://webpack.github.io/docs/configuration.html#devtool
46 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
67 */ 47 */
68 filename: '[name].[chunkhash].bundle.js', 48 devtool: 'source-map',
69 49
70 /** 50 /**
71 * The filename of the SourceMaps for the JavaScript files. 51 * Options affecting the output of the compilation.
72 * They are inside the output.path directory.
73 * 52 *
74 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename 53 * See: http://webpack.github.io/docs/configuration.html#output
75 */ 54 */
76 sourceMapFilename: '[name].[chunkhash].bundle.map', 55 output: {
56 /**
57 * The output directory as absolute path (required).
58 *
59 * See: http://webpack.github.io/docs/configuration.html#output-path
60 */
61 path: helpers.root('dist'),
62
63 /**
64 * Specifies the name of each output file on disk.
65 * IMPORTANT: You must not specify an absolute path here!
66 *
67 * See: http://webpack.github.io/docs/configuration.html#output-filename
68 */
69 filename: '[name].[chunkhash].bundle.js',
70
71 /**
72 * The filename of the SourceMaps for the JavaScript files.
73 * They are inside the output.path directory.
74 *
75 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
76 */
77 sourceMapFilename: '[name].[chunkhash].bundle.map',
78
79 /**
80 * The filename of non-entry chunks as relative path
81 * inside the output.path directory.
82 *
83 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
84 */
85 chunkFilename: '[id].[chunkhash].chunk.js'
86
87 },
88
89 externals: {
90 webtorrent: 'WebTorrent'
91 },
77 92
78 /** 93 /**
79 * The filename of non-entry chunks as relative path 94 * Add additional plugins to the compiler.
80 * inside the output.path directory.
81 * 95 *
82 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename 96 * See: http://webpack.github.io/docs/configuration.html#plugins
83 */ 97 */
84 chunkFilename: '[id].[chunkhash].chunk.js' 98 plugins: [
85 99
86 }, 100 /**
87 101 * Plugin: WebpackMd5Hash
88 externals: { 102 * Description: Plugin to replace a standard webpack chunkhash with md5.
89 webtorrent: 'WebTorrent' 103 *
90 }, 104 * See: https://www.npmjs.com/package/webpack-md5-hash
91 105 */
92 /** 106 new WebpackMd5Hash(),
93 * Add additional plugins to the compiler. 107
94 * 108 /**
95 * See: http://webpack.github.io/docs/configuration.html#plugins 109 * Plugin: DedupePlugin
96 */ 110 * Description: Prevents the inclusion of duplicate code into your bundle
97 plugins: [ 111 * and instead applies a copy of the function at runtime.
98 112 *
99 /** 113 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
100 * Plugin: WebpackMd5Hash 114 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
101 * Description: Plugin to replace a standard webpack chunkhash with md5. 115 */
102 * 116 // new DedupePlugin(),
103 * See: https://www.npmjs.com/package/webpack-md5-hash 117
104 */ 118 /**
105 new WebpackMd5Hash(), 119 * Plugin: DefinePlugin
120 * Description: Define free variables.
121 * Useful for having development builds with debug logging or adding global constants.
122 *
123 * Environment helpers
124 *
125 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
126 */
127 // NOTE: when adding more properties make sure you include them in custom-typings.d.ts
128 new DefinePlugin({
129 'ENV': JSON.stringify(METADATA.ENV),
130 'HMR': METADATA.HMR,
131 'process.env': {
132 'ENV': JSON.stringify(METADATA.ENV),
133 'NODE_ENV': JSON.stringify(METADATA.ENV),
134 'HMR': METADATA.HMR
135 }
136 }),
137
138 /**
139 * Plugin: UglifyJsPlugin
140 * Description: Minimize all JavaScript output of chunks.
141 * Loaders are switched into minimizing mode.
142 *
143 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
144 */
145 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
146 new UglifyJsPlugin({
147 // beautify: true, //debug
148 // mangle: false, //debug
149 // dead_code: false, //debug
150 // unused: false, //debug
151 // deadCode: false, //debug
152 // compress: {
153 // screw_ie8: true,
154 // keep_fnames: true,
155 // drop_debugger: false,
156 // dead_code: false,
157 // unused: false
158 // }, // debug
159 // comments: true, //debug
160
161 beautify: false, // prod
162 mangle: { screw_ie8: true, keep_fnames: true }, // prod
163 compress: { screw_ie8: true }, // prod
164 comments: false // prod
165 }),
166
167 new NormalModuleReplacementPlugin(
168 /angular2-hmr/,
169 helpers.root('config/modules/angular2-hmr-prod.js')
170 )
171
172 /**
173 * Plugin: CompressionPlugin
174 * Description: Prepares compressed versions of assets to serve
175 * them with Content-Encoding
176 *
177 * See: https://github.com/webpack/compression-webpack-plugin
178 */
179 // new CompressionPlugin({
180 // regExp: /\.css$|\.html$|\.js$|\.map$/,
181 // threshold: 2 * 1024
182 // })
106 183
107 /** 184 ],
108 * Plugin: DedupePlugin
109 * Description: Prevents the inclusion of duplicate code into your bundle
110 * and instead applies a copy of the function at runtime.
111 *
112 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
113 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
114 */
115 // new DedupePlugin(),
116 185
117 /** 186 /**
118 * Plugin: DefinePlugin 187 * Static analysis linter for TypeScript advanced options configuration
119 * Description: Define free variables. 188 * Description: An extensible linter for the TypeScript language.
120 * Useful for having development builds with debug logging or adding global constants.
121 *
122 * Environment helpers
123 * 189 *
124 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin 190 * See: https://github.com/wbuchwalter/tslint-loader
125 */ 191 */
126 // NOTE: when adding more properties make sure you include them in custom-typings.d.ts 192 tslint: {
127 new DefinePlugin({ 193 emitErrors: true,
128 'ENV': JSON.stringify(METADATA.ENV), 194 failOnHint: true,
129 'HMR': METADATA.HMR, 195 resourcePath: 'src'
130 'process.env': { 196 },
131 'ENV': JSON.stringify(METADATA.ENV),
132 'NODE_ENV': JSON.stringify(METADATA.ENV),
133 'HMR': METADATA.HMR
134 }
135 }),
136 197
137 /** 198 /**
138 * Plugin: UglifyJsPlugin 199 * Html loader advanced options
139 * Description: Minimize all JavaScript output of chunks.
140 * Loaders are switched into minimizing mode.
141 * 200 *
142 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin 201 * See: https://github.com/webpack/html-loader#advanced-options
143 */ 202 */
144 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines 203 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
145 new UglifyJsPlugin({ 204 htmlLoader: {
146 // beautify: true, //debug 205 minimize: true,
147 // mangle: false, //debug 206 removeAttributeQuotes: false,
148 // dead_code: false, //debug 207 caseSensitive: true,
149 // unused: false, //debug 208 customAttrSurround: [
150 // deadCode: false, //debug 209 [/#/, /(?:)/],
151 // compress: { 210 [/\*/, /(?:)/],
152 // screw_ie8: true, 211 [/\[?\(?/, /(?:)/]
153 // keep_fnames: true, 212 ],
154 // drop_debugger: false, 213 customAttrAssign: [/\)?\]?=/]
155 // dead_code: false, 214 },
156 // unused: false 215
157 // }, // debug 216 /*
158 // comments: true, //debug 217 * Include polyfills or mocks for various node stuff
159 218 * Description: Node configuration
160 beautify: false, // prod
161 mangle: { screw_ie8: true, keep_fnames: true }, // prod
162 compress: { screw_ie8: true }, // prod
163 comments: false // prod
164 }),
165
166 new NormalModuleReplacementPlugin(
167 /angular2-hmr/,
168 helpers.root('config/modules/angular2-hmr-prod.js')
169 )
170
171 /**
172 * Plugin: CompressionPlugin
173 * Description: Prepares compressed versions of assets to serve
174 * them with Content-Encoding
175 * 219 *
176 * See: https://github.com/webpack/compression-webpack-plugin 220 * See: https://webpack.github.io/docs/configuration.html#node
177 */ 221 */
178 // new CompressionPlugin({ 222 node: {
179 // regExp: /\.css$|\.html$|\.js$|\.map$/, 223 global: 'window',
180 // threshold: 2 * 1024 224 crypto: 'empty',
181 // }) 225 process: false,
182 226 module: false,
183 ], 227 clearImmediate: false,
184 228 setImmediate: false
185 /** 229 }
186 * Static analysis linter for TypeScript advanced options configuration 230
187 * Description: An extensible linter for the TypeScript language. 231 })
188 * 232}
189 * See: https://github.com/wbuchwalter/tslint-loader
190 */
191 tslint: {
192 emitErrors: true,
193 failOnHint: true,
194 resourcePath: 'src'
195 },
196
197 /**
198 * Html loader advanced options
199 *
200 * See: https://github.com/webpack/html-loader#advanced-options
201 */
202 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
203 htmlLoader: {
204 minimize: true,
205 removeAttributeQuotes: false,
206 caseSensitive: true,
207 customAttrSurround: [
208 [/#/, /(?:)/],
209 [/\*/, /(?:)/],
210 [/\[?\(?/, /(?:)/]
211 ],
212 customAttrAssign: [/\)?\]?=/]
213 },
214
215 /*
216 * Include polyfills or mocks for various node stuff
217 * Description: Node configuration
218 *
219 * See: https://webpack.github.io/docs/configuration.html#node
220 */
221 node: {
222 global: 'window',
223 crypto: 'empty',
224 process: false,
225 module: false,
226 clearImmediate: false,
227 setImmediate: false
228 }
229
230})