]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/config/webpack.prod.js
Client: adjust viewport height
[github/Chocobozzz/PeerTube.git] / client / config / webpack.prod.js
index 447d47415ccbc331eab705253d5d078cfa2e305c..6d65fcb3739ff3305b9f9358db534dbe7b3f9c86 100644 (file)
@@ -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,22 +163,67 @@ module.exports = function (env) {
         // 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')
+      ),
+
+      // 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.