X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fwebpack%2Fwebpack.video-embed.js;h=aa7c5e550081860396d33a61843e40a606b09752;hb=6fad8e51c47b9d07bea99b777c1f55c10f6d576d;hp=403a65930b56a13daed5fe964eab5c65a8316fcd;hpb=6cca7360eb9027e1544f7513df7da4684061ef7e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/webpack/webpack.video-embed.js b/client/webpack/webpack.video-embed.js index 403a65930..aa7c5e550 100644 --- a/client/webpack/webpack.video-embed.js +++ b/client/webpack/webpack.video-embed.js @@ -1,20 +1,18 @@ 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: { @@ -28,19 +26,26 @@ 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'), + '@root-helpers': path.resolve('src/root-helpers'), + '@shared/models': path.resolve('../shared/models'), + '@shared/core-utils': path.resolve('../shared/core-utils') } }, 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: { @@ -49,13 +54,12 @@ module.exports = function () { test: /\.ts$/, use: [ { - loader: 'awesome-typescript-loader', + loader: 'ts-loader', options: { - configFileName: 'tsconfig.json' + configFile: 'tsconfig.base.json' } } - ], - exclude: [/\.(spec|e2e)\.ts$/] + ] }, { @@ -70,14 +74,15 @@ module.exports = function () { importLoaders: 1 } }, - 'resolve-url-loader', { loader: 'sass-loader', options: { - sourceMap: true, - includePaths: [ - helpers.root('src/sass/include') - ] + sassOptions: { + sourceMap: true, + includePaths: [ + helpers.root('src/sass/include') + ] + } } } ] @@ -89,7 +94,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') ] }, @@ -106,25 +112,38 @@ 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*' ] } }), - new CheckerPlugin(), - new HtmlWebpackPlugin({ 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'] }), /** @@ -142,6 +161,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 @@ -158,28 +198,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 }