]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/webpack/webpack.video-embed.js
Exclude 0p from auto webtorrent quality
[github/Chocobozzz/PeerTube.git] / client / webpack / webpack.video-embed.js
index 979da0dffee0c3f4a90b417d86b6862dc0249947..252040bb7df7a888e7472120e9d930c3bc13639f 100644 (file)
@@ -3,15 +3,12 @@ const path = require('path')
 
 const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
 const HtmlWebpackPlugin = require('html-webpack-plugin')
-const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
-const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
+const TerserPlugin = require('terser-webpack-plugin')
 const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
 const ExtractTextPlugin = require('extract-text-webpack-plugin')
 const PurifyCSSPlugin = require('purifycss-webpack')
 
 module.exports = function () {
-  const isProd = process.env.NODE_ENV === 'production'
-
   const configuration = {
     entry: {
       'video-embed': './src/standalone/videos/embed.ts',
@@ -30,7 +27,7 @@ module.exports = function () {
       modules: [ helpers.root('src'), helpers.root('node_modules') ],
 
       alias: {
-        'video.js$': path.resolve('node_modules/video.js/dist/alt/video.core.js')
+        'video.js$': path.resolve('node_modules/video.js/core.js')
       }
     },
 
@@ -42,7 +39,7 @@ module.exports = function () {
       publicPath: '/client/standalone/videos/'
     },
 
-    // devtool: 'source-map',
+    devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
 
     module: {
 
@@ -72,14 +69,21 @@ module.exports = function () {
                   importLoaders: 1
                 }
               },
-              'resolve-url-loader',
+              // {
+              //   loader: 'resolve-url-loader',
+              //   options: {
+              //     debug: true
+              //   }
+              // },
               {
                 loader: 'sass-loader',
                 options: {
-                  sourceMap: true,
-                  includePaths: [
-                    helpers.root('src/sass/include')
-                  ]
+                  sassOptions: {
+                    sourceMap: true,
+                    includePaths: [
+                      helpers.root('src/sass/include')
+                    ]
+                  }
                 }
               }
             ]
@@ -113,9 +117,9 @@ module.exports = function () {
       }),
 
       new PurifyCSSPlugin({
-        paths: [ 
+        paths: [
           helpers.root('src/standalone/videos/embed.ts'),
-          helpers.root('src/standalone/videos/test-embed.html') 
+          helpers.root('src/standalone/videos/test-embed.html')
         ],
         purifyOptions: {
           minify: true,
@@ -129,7 +133,7 @@ module.exports = function () {
         template: 'src/standalone/videos/embed.html',
         filename: 'embed.html',
         title: 'PeerTube',
-        chunksSortMode: 'dependency',
+        chunksSortMode: 'auto',
         inject: 'body',
         chunks: ['video-embed']
       }),
@@ -138,7 +142,7 @@ module.exports = function () {
         template: '!!html-loader!src/standalone/videos/test-embed.html',
         filename: 'test-embed.html',
         title: 'PeerTube',
-        chunksSortMode: 'dependency',
+        chunksSortMode: 'auto',
         inject: 'body',
         chunks: ['test-embed']
       }),
@@ -158,6 +162,27 @@ module.exports = function () {
       })
     ],
 
+    optimization: {
+      minimizer: [
+        new TerserPlugin({
+          terserOptions: {
+            ecma: 6,
+            warnings: false,
+            ie8: false,
+            mangle: true,
+            compress: {
+              passes: 3,
+              pure_getters: true
+            },
+            output: {
+              ascii_only: true,
+              comments: false
+            }
+          }
+        })
+      ]
+    },
+
     performance: {
       maxEntrypointSize: 700000, // 600kB
       maxAssetSize: 700000
@@ -174,28 +199,5 @@ module.exports = function () {
     }
   }
 
-  if (isProd) {
-    configuration.plugins.push(
-      new UglifyJsPlugin({
-        uglifyOptions: {
-          ecma: 6,
-          warnings: false,
-          ie8: false,
-          mangle: true,
-          compress: {
-            passes: 3,
-            pure_getters: true
-          },
-          output: {
-            ascii_only: true,
-            comments: false
-          }
-        }
-      }),
-
-      new HashedModuleIdsPlugin()
-    )
-  }
-
   return configuration
 }