X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fwebpack%2Fwebpack.video-embed.js;h=2ecbd09afc1300c2417d3306dec8e5587f83aca8;hb=1d4591fd9c724c9409da31612f6d8c008f1cb5e4;hp=252040bb7df7a888e7472120e9d930c3bc13639f;hpb=512decf37ee6d36d0f16bda0f9bec6bf37d132b3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/webpack/webpack.video-embed.js b/client/webpack/webpack.video-embed.js index 252040bb7..2ecbd09af 100644 --- a/client/webpack/webpack.video-embed.js +++ b/client/webpack/webpack.video-embed.js @@ -1,12 +1,11 @@ const helpers = require('./helpers') const path = require('path') -const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin const HtmlWebpackPlugin = require('html-webpack-plugin') const TerserPlugin = require('terser-webpack-plugin') const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') -const ExtractTextPlugin = require('extract-text-webpack-plugin') -const PurifyCSSPlugin = require('purifycss-webpack') +const ProvidePlugin = require('webpack/lib/ProvidePlugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') module.exports = function () { const configuration = { @@ -24,18 +23,39 @@ 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') + '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') ] } }, output: { path: helpers.root('dist/standalone/videos'), - filename: '[name].[hash].bundle.js', + + filename: process.env.ANALYZE_BUNDLE === 'true' + ? '[name].bundle.js' + : '[name].[contenthash].bundle.js', + sourceMapFilename: '[file].map', - chunkFilename: '[id].chunk.js', + + chunkFilename: process.env.ANALYZE_BUNDLE === 'true' + ? '[name].chunk.js' + : '[id].[contenthash].chunk.js', + publicPath: '/client/standalone/videos/' }, @@ -48,46 +68,39 @@ module.exports = function () { test: /\.ts$/, use: [ { - loader: 'awesome-typescript-loader', + loader: 'ts-loader', options: { - configFileName: 'tsconfig.json' + configFile: 'tsconfig.json' } } - ], - exclude: [/\.(spec|e2e)\.ts$/] + ] }, { test: /\.(sass|scss)$/, - use: ExtractTextPlugin.extract({ - fallback: 'style-loader', - use: [ - { - loader: 'css-loader', - options: { + use: [ + MiniCssExtractPlugin.loader, + + { + loader: 'css-loader', + options: { + sourceMap: true, + importLoaders: 1 + } + }, + + { + loader: 'sass-loader', + options: { + sassOptions: { sourceMap: true, - importLoaders: 1 - } - }, - // { - // loader: 'resolve-url-loader', - // options: { - // debug: true - // } - // }, - { - loader: 'sass-loader', - options: { - sassOptions: { - sourceMap: true, - includePaths: [ - helpers.root('src/sass/include') - ] - } + includePaths: [ + helpers.root('src/sass/include') + ] } } - ] - }) + } + ] }, { @@ -112,30 +125,32 @@ module.exports = function () { }, plugins: [ - new ExtractTextPlugin({ - filename: '[name].[hash].css' + new ProvidePlugin({ + process: 'process/browser', + Buffer: [ 'buffer', 'Buffer' ] }), - 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*' ] - } + new MiniCssExtractPlugin({ + filename: process.env.ANALYZE_BUNDLE === 'true' + ? '[name].css' + : '[name].[contenthash].css' }), - new CheckerPlugin(), - new HtmlWebpackPlugin({ template: 'src/standalone/videos/embed.html', filename: 'embed.html', 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({ @@ -144,7 +159,7 @@ module.exports = function () { title: 'PeerTube', chunksSortMode: 'auto', inject: 'body', - chunks: ['test-embed'] + chunks: [ 'test-embed' ] }), /** @@ -189,13 +204,7 @@ module.exports = function () { }, node: { - global: true, - crypto: 'empty', - fs: 'empty', - process: true, - module: false, - clearImmediate: false, - setImmediate: false + global: true } }