]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/webpack/webpack.video-embed.js
Translate copy magnet URI
[github/Chocobozzz/PeerTube.git] / client / webpack / webpack.video-embed.js
index 4a8879031d50abefe6aef338b767dbb0eb1c9df8..909048cca866a318508db4f7a27b6e3b76d6e35f 100644 (file)
@@ -1,19 +1,19 @@
 const helpers = require('./helpers')
+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'
+      'video-embed': './src/standalone/videos/embed.ts',
+      'player': './src/standalone/player/player.ts',
+      'test-embed': './src/standalone/videos/test-embed.ts'
     },
 
     resolve: {
@@ -24,7 +24,11 @@ module.exports = function () {
        */
       extensions: [ '.ts', '.js', '.json', '.scss' ],
 
-      modules: [ helpers.root('src'), helpers.root('node_modules') ]
+      modules: [ helpers.root('src'), helpers.root('node_modules') ],
+
+      alias: {
+        'video.js$': path.resolve('node_modules/video.js/dist/alt/video.core.js')
+      }
     },
 
     output: {
@@ -35,6 +39,8 @@ module.exports = function () {
       publicPath: '/client/standalone/videos/'
     },
 
+    devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
+
     module: {
 
       rules: [
@@ -63,7 +69,12 @@ module.exports = function () {
                   importLoaders: 1
                 }
               },
-              'resolve-url-loader',
+              // {
+              //   loader: 'resolve-url-loader',
+              //   options: {
+              //     debug: true
+              //   }
+              // },
               {
                 loader: 'sass-loader',
                 options: {
@@ -82,7 +93,8 @@ module.exports = function () {
           use: 'raw-loader',
           exclude: [
             helpers.root('src/index.html'),
-            helpers.root('src/standalone/videos/embed.html')
+            helpers.root('src/standalone/videos/embed.html'),
+            helpers.root('src/standalone/videos/test-embed.html')
           ]
         },
 
@@ -103,7 +115,10 @@ module.exports = function () {
       }),
 
       new PurifyCSSPlugin({
-        paths: [ helpers.root('src/standalone/videos/embed.ts') ],
+        paths: [
+          helpers.root('src/standalone/videos/embed.ts'),
+          helpers.root('src/standalone/videos/test-embed.html')
+        ],
         purifyOptions: {
           minify: true,
           whitelist: [ '*vjs*', '*video-js*' ]
@@ -117,7 +132,17 @@ module.exports = function () {
         filename: 'embed.html',
         title: 'PeerTube',
         chunksSortMode: 'dependency',
-        inject: 'body'
+        inject: 'body',
+        chunks: ['video-embed']
+      }),
+
+      new HtmlWebpackPlugin({
+        template: '!!html-loader!src/standalone/videos/test-embed.html',
+        filename: 'test-embed.html',
+        title: 'PeerTube',
+        chunksSortMode: 'dependency',
+        inject: 'body',
+        chunks: ['test-embed']
       }),
 
       /**
@@ -135,6 +160,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
@@ -151,28 +197,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
 }