2 * @author: @AngularClass
5 const helpers = require('./helpers')
6 const webpackMerge = require('webpack-merge') // used to merge webpack configs
7 const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
12 const DefinePlugin = require('webpack/lib/DefinePlugin')
13 const DedupePlugin = require('webpack/lib/optimize/DedupePlugin')
14 const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
15 const CompressionPlugin = require('compression-webpack-plugin')
16 const WebpackMd5Hash = require('webpack-md5-hash')
21 const ENV = process.env.NODE_ENV = process.env.ENV = 'production'
22 const HOST = process.env.HOST || 'localhost'
23 const PORT = process.env.PORT || 8080
24 const METADATA = webpackMerge(commonConfig.metadata, {
31 module.exports = webpackMerge(commonConfig, {
33 * Switch loaders to debug mode.
35 * See: http://webpack.github.io/docs/configuration.html#debug
40 * Developer tool to enhance debugging
42 * See: http://webpack.github.io/docs/configuration.html#devtool
43 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
45 devtool: 'source-map',
48 * Options affecting the output of the compilation.
50 * See: http://webpack.github.io/docs/configuration.html#output
54 * The output directory as absolute path (required).
56 * See: http://webpack.github.io/docs/configuration.html#output-path
58 path: helpers.root('dist'),
61 * Specifies the name of each output file on disk.
62 * IMPORTANT: You must not specify an absolute path here!
64 * See: http://webpack.github.io/docs/configuration.html#output-filename
66 filename: '[name].[chunkhash].bundle.js',
69 * The filename of the SourceMaps for the JavaScript files.
70 * They are inside the output.path directory.
72 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
74 sourceMapFilename: '[name].[chunkhash].bundle.map',
77 * The filename of non-entry chunks as relative path
78 * inside the output.path directory.
80 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
82 chunkFilename: '[id].[chunkhash].chunk.js'
87 * Add additional plugins to the compiler.
89 * See: http://webpack.github.io/docs/configuration.html#plugins
94 * Plugin: WebpackMd5Hash
95 * Description: Plugin to replace a standard webpack chunkhash with md5.
97 * See: https://www.npmjs.com/package/webpack-md5-hash
102 * Plugin: DedupePlugin
103 * Description: Prevents the inclusion of duplicate code into your bundle
104 * and instead applies a copy of the function at runtime.
106 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
107 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
112 * Plugin: DefinePlugin
113 * Description: Define free variables.
114 * Useful for having development builds with debug logging or adding global constants.
116 * Environment helpers
118 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
120 // NOTE: when adding more properties make sure you include them in custom-typings.d.ts
122 'ENV': JSON.stringify(METADATA.ENV),
125 'ENV': JSON.stringify(METADATA.ENV),
126 'NODE_ENV': JSON.stringify(METADATA.ENV),
132 * Plugin: UglifyJsPlugin
133 * Description: Minimize all JavaScript output of chunks.
134 * Loaders are switched into minimizing mode.
136 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
138 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
140 // beautify: true, //debug
141 // mangle: false, //debug
142 // dead_code: false, //debug
143 // unused: false, //debug
144 // deadCode: false, //debug
147 // keep_fnames: true,
148 // drop_debugger: false,
152 // comments: true, //debug
154 beautify: false, // prod
165 comments: false // prod
169 * Plugin: CompressionPlugin
170 * Description: Prepares compressed versions of assets to serve
171 * them with Content-Encoding
173 * See: https://github.com/webpack/compression-webpack-plugin
175 new CompressionPlugin({
176 regExp: /\.css$|\.html$|\.js$|\.map$/,
183 * Static analysis linter for TypeScript advanced options configuration
184 * Description: An extensible linter for the TypeScript language.
186 * See: https://github.com/wbuchwalter/tslint-loader
195 * Html loader advanced options
197 * See: https://github.com/webpack/html-loader#advanced-options
199 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
202 removeAttributeQuotes: false,
204 customAttrSurround: [
209 customAttrAssign: [/\)?\]?=/]
213 * Include polyfills or mocks for various node stuff
214 * Description: Node configuration
216 * See: https://webpack.github.io/docs/configuration.html#node
223 clearImmediate: false,