]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/config/webpack.prod.js
Design signup and login pages
[github/Chocobozzz/PeerTube.git] / client / config / webpack.prod.js
index b950d3fe532a373aee9a590ff47ce202c058b683..e2dde854de12f5ae3f4922a7552b0e1b6dd2ae35 100644 (file)
@@ -11,12 +11,14 @@ const videoEmbedConfig = require('./webpack.video-embed.js')
  * Webpack Plugins
  */
 const DefinePlugin = require('webpack/lib/DefinePlugin')
+const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
 const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
 const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
 const OptimizeJsPlugin = require('optimize-js-plugin')
 const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
-const ModuleConcatenationPlugin = require('webpack/lib/optimize/ModuleConcatenationPlugin')
 const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
+const ExtractTextPlugin = require('extract-text-webpack-plugin')
+
 /**
  * Webpack Constants
  */
@@ -108,7 +110,6 @@ module.exports = function (env) {
        * See: http://webpack.github.io/docs/configuration.html#plugins
        */
       plugins: [
-        new ModuleConcatenationPlugin(),
 
         /**
          * Webpack plugin to optimize a JavaScript file for faster initial load
@@ -121,15 +122,10 @@ module.exports = function (env) {
           sourceMap: false
         }),
 
-        /**
-         * Plugin: DedupePlugin
-         * Description: Prevents the inclusion of duplicate code into your bundle
-         * and instead applies a copy of the function at runtime.
-         *
-         * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
-         * See: https://github.com/webpack/docs/wiki/optimization#deduplication
-         */
-        // new DedupePlugin(),
+        new ExtractTextPlugin({
+          filename: '[name].[contenthash].css',
+          allChunks: true
+        }),
 
         /**
          * Plugin: DefinePlugin
@@ -159,20 +155,18 @@ module.exports = function (env) {
         *
         * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
         */
-        // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
         new UglifyJsPlugin({
           parallel: true,
           uglifyOptions: {
             ie8: false,
             ecma: 6,
-            warnings: true,
+            warnings: false,
             mangle: true,
             output: {
               comments: false,
               beautify: false
             }
-          },
-          warnings: true
+          }
         }),
 
         /**
@@ -251,6 +245,30 @@ module.exports = function (env) {
               path: helpers.root('dist')
             }
           }
+        }),
+
+        new BundleAnalyzerPlugin({
+          // Can be `server`, `static` or `disabled`.
+          // In `server` mode analyzer will start HTTP server to show bundle report.
+          // In `static` mode single HTML file with bundle report will be generated.
+          // In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`.
+          analyzerMode: 'static',
+          // Path to bundle report file that will be generated in `static` mode.
+          // Relative to bundles output directory.
+          reportFilename: 'report.html',
+          // Automatically open report in default browser
+          openAnalyzer: false,
+          // If `true`, Webpack Stats JSON file will be generated in bundles output directory
+          generateStatsFile: true,
+          // Name of Webpack Stats JSON file that will be generated if `generateStatsFile` is `true`.
+          // Relative to bundles output directory.
+          statsFilename: 'stats.json',
+          // Options for `stats.toJson()` method.
+          // For example you can exclude sources of your modules from stats file with `source: false` option.
+          // See more options here: https://github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21
+          statsOptions: null,
+          // Log level. Can be 'info', 'warn', 'error' or 'silent'.
+          logLevel: 'info'
         })
       ],