2017-07-23 07:49:52 -05:00
|
|
|
const helpers = require('./helpers')
|
2018-06-07 09:50:33 -05:00
|
|
|
const path = require('path')
|
2017-07-23 07:49:52 -05:00
|
|
|
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
2018-09-21 02:18:28 -05:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin')
|
2021-05-14 09:56:44 -05:00
|
|
|
const ProvidePlugin = require('webpack/lib/ProvidePlugin')
|
2020-11-19 04:12:01 -06:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2017-07-23 07:49:52 -05:00
|
|
|
|
2017-12-12 04:38:02 -06:00
|
|
|
module.exports = function () {
|
2017-07-23 07:49:52 -05:00
|
|
|
const configuration = {
|
|
|
|
entry: {
|
2018-07-10 10:47:56 -05:00
|
|
|
'video-embed': './src/standalone/videos/embed.ts',
|
2023-07-10 09:41:08 -05:00
|
|
|
'player': './src/standalone/embed-player-api/player.ts',
|
2018-07-10 10:47:56 -05:00
|
|
|
'test-embed': './src/standalone/videos/test-embed.ts'
|
2017-07-23 07:49:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
/*
|
|
|
|
* An array of extensions that should be used to resolve modules.
|
|
|
|
*
|
|
|
|
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
|
|
|
|
*/
|
|
|
|
extensions: [ '.ts', '.js', '.json', '.scss' ],
|
|
|
|
|
2021-02-03 04:44:43 -06:00
|
|
|
modules: [ helpers.root('src'), 'node_modules' ],
|
2018-06-07 09:50:33 -05:00
|
|
|
|
2022-07-21 05:08:47 -05:00
|
|
|
symlinks: true,
|
|
|
|
|
2018-06-07 09:50:33 -05:00
|
|
|
alias: {
|
2020-07-02 09:30:33 -05:00
|
|
|
'video.js$': path.resolve('node_modules/video.js/core.js'),
|
2021-08-06 09:41:08 -05:00
|
|
|
'hls.js$': path.resolve('node_modules/hls.js/dist/hls.light.js'),
|
2020-08-03 11:06:49 -05:00
|
|
|
'@root-helpers': path.resolve('src/root-helpers'),
|
2020-06-26 01:37:26 -05:00
|
|
|
'@shared/models': path.resolve('../shared/models'),
|
2020-08-06 07:58:01 -05:00
|
|
|
'@shared/core-utils': path.resolve('../shared/core-utils')
|
2021-05-14 09:56:44 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
fallback: {
|
|
|
|
fs: [ path.resolve('src/shims/noop.ts') ],
|
|
|
|
path: [ path.resolve('src/shims/path.ts') ],
|
|
|
|
crypto: [ path.resolve('src/shims/noop.ts') ]
|
2018-06-07 09:50:33 -05:00
|
|
|
}
|
2017-07-23 07:49:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: helpers.root('dist/standalone/videos'),
|
2020-08-06 03:26:39 -05:00
|
|
|
|
|
|
|
filename: process.env.ANALYZE_BUNDLE === 'true'
|
|
|
|
? '[name].bundle.js'
|
2021-05-14 09:56:44 -05:00
|
|
|
: '[name].[contenthash].bundle.js',
|
2020-08-06 03:26:39 -05:00
|
|
|
|
2017-07-23 07:49:52 -05:00
|
|
|
sourceMapFilename: '[file].map',
|
2021-02-25 08:00:43 -06:00
|
|
|
|
|
|
|
chunkFilename: process.env.ANALYZE_BUNDLE === 'true'
|
|
|
|
? '[name].chunk.js'
|
2021-05-14 09:56:44 -05:00
|
|
|
: '[id].[contenthash].chunk.js',
|
2021-02-25 08:00:43 -06:00
|
|
|
|
2017-07-23 07:49:52 -05:00
|
|
|
publicPath: '/client/standalone/videos/'
|
|
|
|
},
|
|
|
|
|
2018-09-21 07:08:14 -05:00
|
|
|
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
|
2018-05-29 08:05:03 -05:00
|
|
|
|
2017-07-23 07:49:52 -05:00
|
|
|
module: {
|
|
|
|
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
use: [
|
2023-02-21 07:20:15 -06:00
|
|
|
getBabelLoader(),
|
|
|
|
|
2017-07-23 07:49:52 -05:00
|
|
|
{
|
2020-06-26 01:37:26 -05:00
|
|
|
loader: 'ts-loader',
|
2017-07-23 07:49:52 -05:00
|
|
|
options: {
|
2022-07-15 08:30:14 -05:00
|
|
|
configFile: helpers.root('src/standalone/videos/tsconfig.json')
|
2017-07-23 07:49:52 -05:00
|
|
|
}
|
|
|
|
}
|
2020-06-26 01:37:26 -05:00
|
|
|
]
|
2017-07-23 07:49:52 -05:00
|
|
|
},
|
2021-09-01 08:55:54 -05:00
|
|
|
{
|
2021-11-24 08:37:44 -06:00
|
|
|
test: /\.m?js$/,
|
2023-02-21 07:20:15 -06:00
|
|
|
use: [ getBabelLoader() ]
|
2021-09-01 08:55:54 -05:00
|
|
|
},
|
2017-07-23 07:49:52 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.(sass|scss)$/,
|
2020-11-19 04:12:01 -06:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
importLoaders: 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sassOptions: {
|
2017-07-23 07:49:52 -05:00
|
|
|
sourceMap: true,
|
2020-11-19 04:12:01 -06:00
|
|
|
includePaths: [
|
|
|
|
helpers.root('src/sass/include')
|
|
|
|
]
|
2017-07-23 07:49:52 -05:00
|
|
|
}
|
|
|
|
}
|
2020-11-19 04:12:01 -06:00
|
|
|
}
|
|
|
|
]
|
2017-07-23 07:49:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
exclude: [
|
|
|
|
helpers.root('src/index.html'),
|
2018-07-10 10:47:56 -05:00
|
|
|
helpers.root('src/standalone/videos/embed.html'),
|
|
|
|
helpers.root('src/standalone/videos/test-embed.html')
|
2021-08-17 07:31:30 -05:00
|
|
|
],
|
|
|
|
type: 'asset/source'
|
2017-07-23 07:49:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2021-08-17 07:31:30 -05:00
|
|
|
test: /\.(jpg|png|gif|svg)$/,
|
|
|
|
type: 'asset'
|
2017-07-23 07:49:52 -05:00
|
|
|
},
|
|
|
|
|
2021-08-17 07:31:30 -05:00
|
|
|
{
|
|
|
|
test: /\.(ttf|eot|woff2?)$/,
|
|
|
|
type: 'asset'
|
|
|
|
}
|
2017-07-23 07:49:52 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
2021-05-14 09:56:44 -05:00
|
|
|
new ProvidePlugin({
|
|
|
|
process: 'process/browser',
|
|
|
|
Buffer: [ 'buffer', 'Buffer' ]
|
|
|
|
}),
|
|
|
|
|
2020-11-19 04:12:01 -06:00
|
|
|
new MiniCssExtractPlugin({
|
2020-08-06 03:26:39 -05:00
|
|
|
filename: process.env.ANALYZE_BUNDLE === 'true'
|
|
|
|
? '[name].css'
|
2021-05-14 09:56:44 -05:00
|
|
|
: '[name].[contenthash].css'
|
2017-07-23 07:49:52 -05:00
|
|
|
}),
|
|
|
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: 'src/standalone/videos/embed.html',
|
|
|
|
filename: 'embed.html',
|
|
|
|
title: 'PeerTube',
|
2020-03-31 08:43:17 -05:00
|
|
|
chunksSortMode: 'auto',
|
2018-07-10 10:47:56 -05:00
|
|
|
inject: 'body',
|
2021-05-14 09:56:44 -05:00
|
|
|
chunks: [ 'video-embed' ],
|
2020-12-08 07:51:51 -06:00
|
|
|
minify: {
|
|
|
|
collapseWhitespace: true,
|
|
|
|
removeComments: false,
|
|
|
|
removeRedundantAttributes: true,
|
|
|
|
removeScriptTypeAttributes: true,
|
|
|
|
removeStyleLinkTypeAttributes: true,
|
|
|
|
useShortDoctype: true
|
|
|
|
}
|
2018-07-10 10:47:56 -05:00
|
|
|
}),
|
|
|
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: '!!html-loader!src/standalone/videos/test-embed.html',
|
|
|
|
filename: 'test-embed.html',
|
|
|
|
title: 'PeerTube',
|
2020-03-31 08:43:17 -05:00
|
|
|
chunksSortMode: 'auto',
|
2018-07-10 10:47:56 -05:00
|
|
|
inject: 'body',
|
2021-05-14 09:56:44 -05:00
|
|
|
chunks: [ 'test-embed' ]
|
2017-07-23 07:49:52 -05:00
|
|
|
})
|
|
|
|
],
|
|
|
|
|
2018-09-21 02:18:28 -05:00
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
|
|
|
ecma: 6,
|
|
|
|
warnings: false,
|
|
|
|
ie8: false,
|
2023-02-27 08:18:47 -06:00
|
|
|
safari10: false,
|
2018-09-21 02:18:28 -05:00
|
|
|
mangle: true,
|
|
|
|
compress: {
|
|
|
|
passes: 3,
|
|
|
|
pure_getters: true
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
ascii_only: true,
|
|
|
|
comments: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-04-06 09:06:43 -05:00
|
|
|
performance: {
|
2018-05-14 03:57:07 -05:00
|
|
|
maxEntrypointSize: 700000, // 600kB
|
|
|
|
maxAssetSize: 700000
|
2018-04-06 09:06:43 -05:00
|
|
|
},
|
|
|
|
|
2017-07-23 07:49:52 -05:00
|
|
|
node: {
|
2021-05-14 09:56:44 -05:00
|
|
|
global: true
|
2017-07-23 07:49:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return configuration
|
|
|
|
}
|
2023-02-21 07:20:15 -06:00
|
|
|
|
|
|
|
function getBabelLoader () {
|
|
|
|
return {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
[
|
|
|
|
'@babel/preset-env', {
|
2023-02-27 08:18:47 -06:00
|
|
|
targets: 'last 1 Chrome version, last 2 Edge major versions, Firefox ESR, Safari >= 12, ios_saf >= 12'
|
2023-02-21 07:20:15 -06:00
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|