/**
* Webpack Plugins
*/
-// const ProvidePlugin = require('webpack/lib/ProvidePlugin')
const DefinePlugin = require('webpack/lib/DefinePlugin')
-const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
-// const IgnorePlugin = require('webpack/lib/IgnorePlugin')
-// const DedupePlugin = require('webpack/lib/optimize/DedupePlugin')
+const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
+const OptimizeJsPlugin = require('optimize-js-plugin')
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
-const WebpackMd5Hash = require('webpack-md5-hash')
+const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
/**
* Webpack Constants
host: HOST,
port: PORT,
ENV: ENV,
- HMR: false
+ HMR: false,
+ API_URL: ''
})
module.exports = function (env) {
*
* See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
*/
- sourceMapFilename: '[name].[chunkhash].bundle.map',
+ sourceMapFilename: '[file].map',
/**
* The filename of non-entry chunks as relative path
*
* See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
*/
- chunkFilename: '[id].[chunkhash].chunk.js',
+ chunkFilename: '[name].[chunkhash].chunk.js',
publicPath: '/client/'
},
- externals: {
- webtorrent: 'WebTorrent'
- },
-
/**
* Add additional plugins to the compiler.
*
plugins: [
/**
- * Plugin: WebpackMd5Hash
- * Description: Plugin to replace a standard webpack chunkhash with md5.
+ * Webpack plugin to optimize a JavaScript file for faster initial load
+ * by wrapping eagerly-invoked functions.
*
- * See: https://www.npmjs.com/package/webpack-md5-hash
+ * See: https://github.com/vigneshshanmugam/optimize-js-plugin
*/
- new WebpackMd5Hash(),
+
+ new OptimizeJsPlugin({
+ sourceMap: false
+ }),
/**
* Plugin: DedupePlugin
new DefinePlugin({
'ENV': JSON.stringify(METADATA.ENV),
'HMR': METADATA.HMR,
+ 'API_URL': JSON.stringify(METADATA.API_URL),
+ 'process.version': JSON.stringify(process.version),
'process.env': {
'ENV': JSON.stringify(METADATA.ENV),
'NODE_ENV': JSON.stringify(METADATA.ENV),
'HMR': METADATA.HMR
}
}),
-/**
+ /**
* Plugin: UglifyJsPlugin
* Description: Minimize all JavaScript output of chunks.
* Loaders are switched into minimizing mode.
// comments: true, //debug
beautify: false, // prod
+ output: {
+ comments: false
+ }, // prod
mangle: {
- screw_ie8: true,
- keep_fnames: true
+ screw_ie8: true
}, // prod
compress: {
screw_ie8: true,
- warnings: false
- }, // prod
- comments: false // prod
+ warnings: false,
+ conditionals: true,
+ unused: true,
+ comparisons: true,
+ sequences: true,
+ dead_code: true,
+ evaluate: true,
+ if_return: true,
+ join_vars: true,
+ negate_iife: false // we need this for lazy v8
+ }
}),
new NormalModuleReplacementPlugin(
/angular2-hmr/,
- helpers.root('config/modules/angular2-hmr-prod.js')
+ helpers.root('config/empty.js')
),
+ new NormalModuleReplacementPlugin(
+ /zone\.js(\\|\/)dist(\\|\/)long-stack-trace-zone/,
+ helpers.root('config/empty.js')
+ ),
+
+ new HashedModuleIdsPlugin(),
+
/**
* Plugin: IgnorePlugin
* Description: Don’t generate modules for requests matching the provided RegExp.
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
*/
new LoaderOptionsPlugin({
+ minimize: true,
debug: false,
options: {
node: {
global: true,
crypto: 'empty',
- process: false,
+ fs: 'empty',
+ process: true,
module: false,
clearImmediate: false,
setImmediate: false