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 ProvidePlugin = require('webpack/lib/ProvidePlugin')
13 const DefinePlugin = require('webpack/lib/DefinePlugin')
14 const DedupePlugin = require('webpack/lib/optimize/DedupePlugin')
15 const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
16 const CompressionPlugin = require('compression-webpack-plugin')
17 const WebpackMd5Hash = require('webpack-md5-hash')
22 const ENV = process.env.NODE_ENV = process.env.ENV = 'production'
23 const HOST = process.env.HOST || 'localhost'
24 const PORT = process.env.PORT || 8080
25 const METADATA = webpackMerge(commonConfig.metadata, {
32 module.exports = webpackMerge(commonConfig, {
34 * Switch loaders to debug mode.
36 * See: http://webpack.github.io/docs/configuration.html#debug
41 * Developer tool to enhance debugging
43 * See: http://webpack.github.io/docs/configuration.html#devtool
44 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
46 devtool: 'source-map',
49 * Options affecting the output of the compilation.
51 * See: http://webpack.github.io/docs/configuration.html#output
55 * The output directory as absolute path (required).
57 * See: http://webpack.github.io/docs/configuration.html#output-path
59 path: helpers.root('dist'),
62 * Specifies the name of each output file on disk.
63 * IMPORTANT: You must not specify an absolute path here!
65 * See: http://webpack.github.io/docs/configuration.html#output-filename
67 filename: '[name].[chunkhash].bundle.js',
70 * The filename of the SourceMaps for the JavaScript files.
71 * They are inside the output.path directory.
73 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
75 sourceMapFilename: '[name].[chunkhash].bundle.map',
78 * The filename of non-entry chunks as relative path
79 * inside the output.path directory.
81 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
83 chunkFilename: '[id].[chunkhash].chunk.js'
88 * Add additional plugins to the compiler.
90 * See: http://webpack.github.io/docs/configuration.html#plugins
95 * Plugin: WebpackMd5Hash
96 * Description: Plugin to replace a standard webpack chunkhash with md5.
98 * See: https://www.npmjs.com/package/webpack-md5-hash
100 new WebpackMd5Hash(),
103 * Plugin: DedupePlugin
104 * Description: Prevents the inclusion of duplicate code into your bundle
105 * and instead applies a copy of the function at runtime.
107 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
108 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
113 * Plugin: DefinePlugin
114 * Description: Define free variables.
115 * Useful for having development builds with debug logging or adding global constants.
117 * Environment helpers
119 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
121 // NOTE: when adding more properties make sure you include them in custom-typings.d.ts
123 'ENV': JSON.stringify(METADATA.ENV),
126 'ENV': JSON.stringify(METADATA.ENV),
127 'NODE_ENV': JSON.stringify(METADATA.ENV),
133 * Plugin: UglifyJsPlugin
134 * Description: Minimize all JavaScript output of chunks.
135 * Loaders are switched into minimizing mode.
137 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
139 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
141 // beautify: true, //debug
142 // mangle: false, //debug
143 // dead_code: false, //debug
144 // unused: false, //debug
145 // deadCode: false, //debug
148 // keep_fnames: true,
149 // drop_debugger: false,
153 // comments: true, //debug
155 beautify: false, // prod
166 comments: false // prod
170 * Plugin: CompressionPlugin
171 * Description: Prepares compressed versions of assets to serve
172 * them with Content-Encoding
174 * See: https://github.com/webpack/compression-webpack-plugin
176 new CompressionPlugin({
177 regExp: /\.css$|\.html$|\.js$|\.map$/,
184 * Static analysis linter for TypeScript advanced options configuration
185 * Description: An extensible linter for the TypeScript language.
187 * See: https://github.com/wbuchwalter/tslint-loader
196 * Html loader advanced options
198 * See: https://github.com/webpack/html-loader#advanced-options
200 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
203 removeAttributeQuotes: false,
205 customAttrSurround: [
210 customAttrAssign: [/\)?\]?=/]
214 * Include polyfills or mocks for various node stuff
215 * Description: Node configuration
217 * See: https://webpack.github.io/docs/configuration.html#node
224 clearImmediate: false,