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 NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
15 // const IgnorePlugin = require('webpack/lib/IgnorePlugin')
16 // const DedupePlugin = require('webpack/lib/optimize/DedupePlugin')
17 const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
18 const WebpackMd5Hash = require('webpack-md5-hash')
23 const ENV = process.env.NODE_ENV = process.env.ENV = 'production'
24 const HOST = process.env.HOST || 'localhost'
25 const PORT = process.env.PORT || 8080
26 const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
33 module.exports = webpackMerge(commonConfig, {
35 * Switch loaders to debug mode.
37 * See: http://webpack.github.io/docs/configuration.html#debug
42 * Developer tool to enhance debugging
44 * See: http://webpack.github.io/docs/configuration.html#devtool
45 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
47 devtool: 'source-map',
50 * Options affecting the output of the compilation.
52 * See: http://webpack.github.io/docs/configuration.html#output
56 * The output directory as absolute path (required).
58 * See: http://webpack.github.io/docs/configuration.html#output-path
60 path: helpers.root('dist'),
63 * Specifies the name of each output file on disk.
64 * IMPORTANT: You must not specify an absolute path here!
66 * See: http://webpack.github.io/docs/configuration.html#output-filename
68 filename: '[name].[chunkhash].bundle.js',
71 * The filename of the SourceMaps for the JavaScript files.
72 * They are inside the output.path directory.
74 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
76 sourceMapFilename: '[name].[chunkhash].bundle.map',
79 * The filename of non-entry chunks as relative path
80 * inside the output.path directory.
82 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
84 chunkFilename: '[id].[chunkhash].chunk.js'
89 webtorrent: 'WebTorrent'
93 * Add additional plugins to the compiler.
95 * See: http://webpack.github.io/docs/configuration.html#plugins
100 * Plugin: WebpackMd5Hash
101 * Description: Plugin to replace a standard webpack chunkhash with md5.
103 * See: https://www.npmjs.com/package/webpack-md5-hash
105 new WebpackMd5Hash(),
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.
112 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
113 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
115 // new DedupePlugin(),
118 * Plugin: DefinePlugin
119 * Description: Define free variables.
120 * Useful for having development builds with debug logging or adding global constants.
122 * Environment helpers
124 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
126 // NOTE: when adding more properties make sure you include them in custom-typings.d.ts
128 'ENV': JSON.stringify(METADATA.ENV),
131 'ENV': JSON.stringify(METADATA.ENV),
132 'NODE_ENV': JSON.stringify(METADATA.ENV),
138 * Plugin: UglifyJsPlugin
139 * Description: Minimize all JavaScript output of chunks.
140 * Loaders are switched into minimizing mode.
142 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
144 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
146 // beautify: true, //debug
147 // mangle: false, //debug
148 // dead_code: false, //debug
149 // unused: false, //debug
150 // deadCode: false, //debug
153 // keep_fnames: true,
154 // drop_debugger: false,
158 // comments: true, //debug
160 beautify: false, // prod
161 mangle: { screw_ie8: true, keep_fnames: true }, // prod
162 compress: { screw_ie8: true }, // prod
163 comments: false // prod
166 new NormalModuleReplacementPlugin(
168 helpers.root('config/modules/angular2-hmr-prod.js')
172 * Plugin: CompressionPlugin
173 * Description: Prepares compressed versions of assets to serve
174 * them with Content-Encoding
176 * See: https://github.com/webpack/compression-webpack-plugin
178 // new CompressionPlugin({
179 // regExp: /\.css$|\.html$|\.js$|\.map$/,
180 // threshold: 2 * 1024
186 * Static analysis linter for TypeScript advanced options configuration
187 * Description: An extensible linter for the TypeScript language.
189 * See: https://github.com/wbuchwalter/tslint-loader
198 * Html loader advanced options
200 * See: https://github.com/webpack/html-loader#advanced-options
202 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
205 removeAttributeQuotes: false,
207 customAttrSurround: [
212 customAttrAssign: [/\)?\]?=/]
216 * Include polyfills or mocks for various node stuff
217 * Description: Node configuration
219 * See: https://webpack.github.io/docs/configuration.html#node
226 clearImmediate: false,