X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fwebpack%2Fwebpack.video-embed.js;h=b6a1c4c050f918f4d8db03f57445c1e1ac821ea1;hb=4504f09f6e85f09b0489debb547a17209d7176ea;hp=5a4e35deac3e1ce5e9599b7e396e9dc7cce07dc9;hpb=f6a7c82ca51896a433bc2264c52afd6981c7c4c6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/webpack/webpack.video-embed.js b/client/webpack/webpack.video-embed.js index 5a4e35dea..b6a1c4c05 100644 --- a/client/webpack/webpack.video-embed.js +++ b/client/webpack/webpack.video-embed.js @@ -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,18 +24,28 @@ 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/core.js'), + '@root-helpers': path.resolve('src/root-helpers'), + '@shared': path.resolve('../shared') + } }, output: { path: helpers.root('dist/standalone/videos'), - filename: '[name].[hash].bundle.js', + + filename: process.env.ANALYZE_BUNDLE === 'true' + ? '[name].bundle.js' + : '[name].[hash].bundle.js', + sourceMapFilename: '[file].map', - chunkFilename: '[id].chunk.js', + chunkFilename: '[id].[hash].chunk.js', publicPath: '/client/standalone/videos/' }, - // devtool: 'source-map', + devtool: process.env.NODE_ENV === 'production' ? false : 'source-map', module: { @@ -65,14 +75,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') + ] + } } } ] @@ -84,7 +101,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') ] }, @@ -101,11 +119,16 @@ module.exports = function () { plugins: [ new ExtractTextPlugin({ - filename: '[name].[hash].css' + filename: process.env.ANALYZE_BUNDLE === 'true' + ? '[name].css' + : '[name].[hash].css' }), 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*' ] @@ -118,8 +141,18 @@ module.exports = function () { template: 'src/standalone/videos/embed.html', filename: 'embed.html', title: 'PeerTube', - chunksSortMode: 'dependency', - inject: 'body' + chunksSortMode: 'auto', + inject: 'body', + chunks: ['video-embed'] + }), + + new HtmlWebpackPlugin({ + template: '!!html-loader!src/standalone/videos/test-embed.html', + filename: 'test-embed.html', + title: 'PeerTube', + chunksSortMode: 'auto', + inject: 'body', + chunks: ['test-embed'] }), /** @@ -137,6 +170,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 @@ -153,28 +207,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 }