X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fconfig%2Fwebpack.prod.js;h=6d65fcb3739ff3305b9f9358db534dbe7b3f9c86;hb=efbf0ed7f2a5d01fbcacc26dae1ff254c46b0ce5;hp=98507ff8e65404af41a0d1b7770af536e07acc5e;hpb=437cf8b531652a4b101ec279dea7661e8dfb8cda;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js index 98507ff8e..6d65fcb37 100644 --- a/client/config/webpack.prod.js +++ b/client/config/webpack.prod.js @@ -9,12 +9,10 @@ const commonConfig = require('./webpack.common.js') // the settings that are com /** * 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') @@ -101,6 +99,17 @@ module.exports = function (env) { */ new WebpackMd5Hash(), + /** + * Webpack plugin to optimize a JavaScript file for faster initial load + * by wrapping eagerly-invoked functions. + * + * See: https://github.com/vigneshshanmugam/optimize-js-plugin + */ + + new OptimizeJsPlugin({ + sourceMap: false + }), + /** * Plugin: DedupePlugin * Description: Prevents the inclusion of duplicate code into your bundle @@ -154,21 +163,67 @@ module.exports = function (env) { // comments: true, //debug beautify: false, // prod - mangle: { - screw_ie8: true, - keep_fnames: true + output: { + comments: false }, // prod - compress: { + mangle: { screw_ie8: true }, // prod - comments: false // prod + compress: { + screw_ie8: true, + 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') + ), + + // AoT + // new NormalModuleReplacementPlugin( + // /@angular(\\|\/)upgrade/, + // helpers.root('config/empty.js') + // ), + // new NormalModuleReplacementPlugin( + // /@angular(\\|\/)compiler/, + // helpers.root('config/empty.js') + // ), + // new NormalModuleReplacementPlugin( + // /@angular(\\|\/)platform-browser-dynamic/, + // helpers.root('config/empty.js') + // ), + // new NormalModuleReplacementPlugin( + // /dom(\\|\/)debug(\\|\/)ng_probe/, + // helpers.root('config/empty.js') + // ), + // new NormalModuleReplacementPlugin( + // /dom(\\|\/)debug(\\|\/)by/, + // helpers.root('config/empty.js') + // ), + // new NormalModuleReplacementPlugin( + // /src(\\|\/)debug(\\|\/)debug_node/, + // helpers.root('config/empty.js') + // ), + // new NormalModuleReplacementPlugin( + // /src(\\|\/)debug(\\|\/)debug_renderer/, + // helpers.root('config/empty.js') + // ), + /** * Plugin: IgnorePlugin * Description: Don’t generate modules for requests matching the provided RegExp.