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.js204
1 files changed, 116 insertions, 88 deletions
diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js
index 46db54482..ce6886af6 100644
--- a/client/config/webpack.prod.js
+++ b/client/config/webpack.prod.js
@@ -12,6 +12,7 @@ const commonConfig = require('./webpack.common.js') // the settings that are com
12// const ProvidePlugin = require('webpack/lib/ProvidePlugin') 12// const ProvidePlugin = require('webpack/lib/ProvidePlugin')
13const DefinePlugin = require('webpack/lib/DefinePlugin') 13const DefinePlugin = require('webpack/lib/DefinePlugin')
14const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin') 14const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
15const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
15// const IgnorePlugin = require('webpack/lib/IgnorePlugin') 16// const IgnorePlugin = require('webpack/lib/IgnorePlugin')
16// const DedupePlugin = require('webpack/lib/optimize/DedupePlugin') 17// const DedupePlugin = require('webpack/lib/optimize/DedupePlugin')
17const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin') 18const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
@@ -33,57 +34,52 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
33module.exports = function (env) { 34module.exports = function (env) {
34 return webpackMerge(commonConfig({env: ENV}), { 35 return webpackMerge(commonConfig({env: ENV}), {
35 /** 36 /**
36 * Switch loaders to debug mode. 37 * Developer tool to enhance debugging
37 * 38 *
38 * See: http://webpack.github.io/docs/configuration.html#debug 39 * See: http://webpack.github.io/docs/configuration.html#devtool
39 */ 40 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
40 debug: false, 41 */
41
42 /**
43 * Developer tool to enhance debugging
44 *
45 * See: http://webpack.github.io/docs/configuration.html#devtool
46 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
47 */
48 devtool: 'source-map', 42 devtool: 'source-map',
49 43
50 /** 44 /**
51 * Options affecting the output of the compilation. 45 * Options affecting the output of the compilation.
52 * 46 *
53 * See: http://webpack.github.io/docs/configuration.html#output 47 * See: http://webpack.github.io/docs/configuration.html#output
54 */ 48 */
55 output: { 49 output: {
50
56 /** 51 /**
57 * The output directory as absolute path (required). 52 * The output directory as absolute path (required).
58 * 53 *
59 * See: http://webpack.github.io/docs/configuration.html#output-path 54 * See: http://webpack.github.io/docs/configuration.html#output-path
60 */ 55 */
61 path: helpers.root('dist'), 56 path: helpers.root('dist'),
62 57
63 /** 58 /**
64 * Specifies the name of each output file on disk. 59 * Specifies the name of each output file on disk.
65 * IMPORTANT: You must not specify an absolute path here! 60 * IMPORTANT: You must not specify an absolute path here!
66 * 61 *
67 * See: http://webpack.github.io/docs/configuration.html#output-filename 62 * See: http://webpack.github.io/docs/configuration.html#output-filename
68 */ 63 */
69 filename: '[name].[chunkhash].bundle.js', 64 filename: '[name].[chunkhash].bundle.js',
70 65
71 /** 66 /**
72 * The filename of the SourceMaps for the JavaScript files. 67 * The filename of the SourceMaps for the JavaScript files.
73 * They are inside the output.path directory. 68 * They are inside the output.path directory.
74 * 69 *
75 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename 70 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
76 */ 71 */
77 sourceMapFilename: '[name].[chunkhash].bundle.map', 72 sourceMapFilename: '[name].[chunkhash].bundle.map',
78 73
79 /** 74 /**
80 * The filename of non-entry chunks as relative path 75 * The filename of non-entry chunks as relative path
81 * inside the output.path directory. 76 * inside the output.path directory.
82 * 77 *
83 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename 78 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
84 */ 79 */
85 chunkFilename: '[id].[chunkhash].chunk.js' 80 chunkFilename: '[id].[chunkhash].chunk.js',
86 81
82 publicPath: '/client/'
87 }, 83 },
88 84
89 externals: { 85 externals: {
@@ -134,14 +130,13 @@ module.exports = function (env) {
134 'HMR': METADATA.HMR 130 'HMR': METADATA.HMR
135 } 131 }
136 }), 132 }),
137 133/**
138 /** 134 * Plugin: UglifyJsPlugin
139 * Plugin: UglifyJsPlugin 135 * Description: Minimize all JavaScript output of chunks.
140 * Description: Minimize all JavaScript output of chunks. 136 * Loaders are switched into minimizing mode.
141 * Loaders are switched into minimizing mode. 137 *
142 * 138 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
143 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin 139 */
144 */
145 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines 140 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
146 new UglifyJsPlugin({ 141 new UglifyJsPlugin({
147 // beautify: true, //debug 142 // beautify: true, //debug
@@ -159,68 +154,101 @@ module.exports = function (env) {
159 // comments: true, //debug 154 // comments: true, //debug
160 155
161 beautify: false, // prod 156 beautify: false, // prod
162 mangle: { screw_ie8: true, keep_fnames: true }, // prod 157 mangle: {
163 compress: { screw_ie8: true }, // prod 158 screw_ie8: true,
159 keep_fnames: true
160 }, // prod
161 compress: {
162 screw_ie8: true
163 }, // prod
164 comments: false // prod 164 comments: false // prod
165 }), 165 }),
166 166
167 new NormalModuleReplacementPlugin( 167 new NormalModuleReplacementPlugin(
168 /angular2-hmr/, 168 /angular2-hmr/,
169 helpers.root('config/modules/angular2-hmr-prod.js') 169 helpers.root('config/modules/angular2-hmr-prod.js')
170 ) 170 ),
171 171
172 /** 172 /**
173 * Plugin: CompressionPlugin 173 * Plugin: IgnorePlugin
174 * Description: Prepares compressed versions of assets to serve 174 * Description: Don’t generate modules for requests matching the provided RegExp.
175 * them with Content-Encoding 175 *
176 * 176 * See: http://webpack.github.io/docs/list-of-plugins.html#ignoreplugin
177 * See: https://github.com/webpack/compression-webpack-plugin 177 */
178 */ 178
179 // new IgnorePlugin(/angular2-hmr/),
180
181 /**
182 * Plugin: CompressionPlugin
183 * Description: Prepares compressed versions of assets to serve
184 * them with Content-Encoding
185 *
186 * See: https://github.com/webpack/compression-webpack-plugin
187 */
188 // install compression-webpack-plugin
179 // new CompressionPlugin({ 189 // new CompressionPlugin({
180 // regExp: /\.css$|\.html$|\.js$|\.map$/, 190 // regExp: /\.css$|\.html$|\.js$|\.map$/,
181 // threshold: 2 * 1024 191 // threshold: 2 * 1024
182 // }) 192 // })
183 193
184 ], 194 /**
195 * Plugin LoaderOptionsPlugin (experimental)
196 *
197 * See: https://gist.github.com/sokra/27b24881210b56bbaff7
198 */
199 new LoaderOptionsPlugin({
200 debug: false,
201 options: {
185 202
186 /** 203 /**
187 * Static analysis linter for TypeScript advanced options configuration 204 * Static analysis linter for TypeScript advanced options configuration
188 * Description: An extensible linter for the TypeScript language. 205 * Description: An extensible linter for the TypeScript language.
189 * 206 *
190 * See: https://github.com/wbuchwalter/tslint-loader 207 * See: https://github.com/wbuchwalter/tslint-loader
191 */ 208 */
192 tslint: { 209 tslint: {
193 emitErrors: true, 210 emitErrors: true,
194 failOnHint: true, 211 failOnHint: true,
195 resourcePath: 'src' 212 resourcePath: 'src'
196 }, 213 },
197 214
198 /** 215 /**
199 * Html loader advanced options 216 * Html loader advanced options
200 * 217 *
201 * See: https://github.com/webpack/html-loader#advanced-options 218 * See: https://github.com/webpack/html-loader#advanced-options
202 */ 219 */
203 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor 220 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
204 htmlLoader: { 221 htmlLoader: {
205 minimize: true, 222 minimize: true,
206 removeAttributeQuotes: false, 223 removeAttributeQuotes: false,
207 caseSensitive: true, 224 caseSensitive: true,
208 customAttrSurround: [ 225 customAttrSurround: [
209 [/#/, /(?:)/], 226 [/#/, /(?:)/],
210 [/\*/, /(?:)/], 227 [/\*/, /(?:)/],
211 [/\[?\(?/, /(?:)/] 228 [/\[?\(?/, /(?:)/]
212 ], 229 ],
213 customAttrAssign: [/\)?\]?=/] 230 customAttrAssign: [/\)?\]?=/]
214 }, 231 },
232
233 // FIXME: Remove
234 // https://github.com/bholloway/resolve-url-loader/issues/36
235 // https://github.com/jtangelder/sass-loader/issues/289
236 context: __dirname,
237 output: {
238 path: helpers.root('dist')
239 }
240 }
241 })
242 ],
215 243
216 /* 244 /*
217 * Include polyfills or mocks for various node stuff 245 * Include polyfills or mocks for various node stuff
218 * Description: Node configuration 246 * Description: Node configuration
219 * 247 *
220 * See: https://webpack.github.io/docs/configuration.html#node 248 * See: https://webpack.github.io/docs/configuration.html#node
221 */ 249 */
222 node: { 250 node: {
223 global: 'window', 251 global: true,
224 crypto: 'empty', 252 crypto: 'empty',
225 process: false, 253 process: false,
226 module: false, 254 module: false,