X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fwebpack%2Fwebpack.video-embed.js;h=4c7f7e19cab8e81bce36328da17eb941298da94f;hb=87244e54bbb7e455a394c69386fb5021237627ac;hp=b20a2187280ea735f9878edfdb2bab5b2685af2e;hpb=4f926722ea6784ea389013378fd233f59077ec8a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/webpack/webpack.video-embed.js b/client/webpack/webpack.video-embed.js index b20a21872..4c7f7e19c 100644 --- a/client/webpack/webpack.video-embed.js +++ b/client/webpack/webpack.video-embed.js @@ -3,8 +3,7 @@ const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const TerserPlugin = require('terser-webpack-plugin') -const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') -const PurifyCSSPlugin = require('purifycss-webpack') +const ProvidePlugin = require('webpack/lib/ProvidePlugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') module.exports = function () { @@ -23,13 +22,23 @@ module.exports = function () { */ extensions: [ '.ts', '.js', '.json', '.scss' ], - modules: [ helpers.root('src'), helpers.root('node_modules') ], + modules: [ helpers.root('src'), 'node_modules' ], alias: { 'video.js$': path.resolve('node_modules/video.js/core.js'), + 'hls.js$': path.resolve('node_modules/hls.js/dist/hls.light.js'), '@root-helpers': path.resolve('src/root-helpers'), '@shared/models': path.resolve('../shared/models'), '@shared/core-utils': path.resolve('../shared/core-utils') + }, + + fallback: { + fs: [ path.resolve('src/shims/noop.ts') ], + http: [ path.resolve('src/shims/http.ts') ], + https: [ path.resolve('src/shims/https.ts') ], + path: [ path.resolve('src/shims/path.ts') ], + stream: [ path.resolve('src/shims/stream.ts') ], + crypto: [ path.resolve('src/shims/noop.ts') ] } }, @@ -38,10 +47,14 @@ module.exports = function () { filename: process.env.ANALYZE_BUNDLE === 'true' ? '[name].bundle.js' - : '[name].[hash].bundle.js', + : '[name].[contenthash].bundle.js', sourceMapFilename: '[file].map', - chunkFilename: '[id].[hash].chunk.js', + + chunkFilename: process.env.ANALYZE_BUNDLE === 'true' + ? '[name].chunk.js' + : '[id].[contenthash].chunk.js', + publicPath: '/client/standalone/videos/' }, @@ -56,7 +69,7 @@ module.exports = function () { { loader: 'ts-loader', options: { - configFile: 'tsconfig.base.json' + configFile: 'tsconfig.json' } } ] @@ -91,41 +104,37 @@ module.exports = function () { { test: /\.html$/, - use: 'raw-loader', exclude: [ helpers.root('src/index.html'), helpers.root('src/standalone/videos/embed.html'), helpers.root('src/standalone/videos/test-embed.html') - ] + ], + type: 'asset/source' }, { - test: /\.(jpg|png|gif)$/, - use: 'url-loader' + test: /\.(jpg|png|gif|svg)$/, + type: 'asset' }, - { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' }, - { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'file-loader' } + { + test: /\.(ttf|eot|woff2?)$/, + type: 'asset' + } ] }, plugins: [ + new ProvidePlugin({ + process: 'process/browser', + Buffer: [ 'buffer', 'Buffer' ] + }), + new MiniCssExtractPlugin({ filename: process.env.ANALYZE_BUNDLE === 'true' ? '[name].css' - : '[name].[hash].css' - }), - - new PurifyCSSPlugin({ - paths: [ - helpers.root('src/standalone/videos/embed.ts'), - helpers.root('src/standalone/videos/test-embed.html') - ], - purifyOptions: { - minify: true, - whitelist: [ '*vjs*', '*video-js*' ] - } + : '[name].[contenthash].css' }), new HtmlWebpackPlugin({ @@ -134,7 +143,15 @@ module.exports = function () { title: 'PeerTube', chunksSortMode: 'auto', inject: 'body', - chunks: ['video-embed'] + chunks: [ 'video-embed' ], + minify: { + collapseWhitespace: true, + removeComments: false, + removeRedundantAttributes: true, + removeScriptTypeAttributes: true, + removeStyleLinkTypeAttributes: true, + useShortDoctype: true + } }), new HtmlWebpackPlugin({ @@ -143,21 +160,7 @@ module.exports = function () { title: 'PeerTube', chunksSortMode: 'auto', inject: 'body', - chunks: ['test-embed'] - }), - - /** - * Plugin LoaderOptionsPlugin (experimental) - * - * See: https://gist.github.com/sokra/27b24881210b56bbaff7 - */ - new LoaderOptionsPlugin({ - options: { - context: __dirname, - output: { - path: helpers.root('dist') - } - } + chunks: [ 'test-embed' ] }) ], @@ -188,13 +191,7 @@ module.exports = function () { }, node: { - global: true, - crypto: 'empty', - fs: 'empty', - process: true, - module: false, - clearImmediate: false, - setImmediate: false + global: true } }