2017-07-23 14:49:52 +02:00
|
|
|
const helpers = require('./helpers')
|
2018-06-07 16:50:33 +02:00
|
|
|
const path = require('path')
|
2017-07-23 14:49:52 +02:00
|
|
|
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
2018-09-21 09:18:28 +02:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin')
|
2017-12-12 11:38:02 +01:00
|
|
|
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
|
2020-11-19 11:12:01 +01:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2017-07-23 14:49:52 +02:00
|
|
|
|
2017-12-12 11:38:02 +01:00
|
|
|
module.exports = function () {
|
2017-07-23 14:49:52 +02:00
|
|
|
const configuration = {
|
|
|
|
entry: {
|
2018-07-10 17:47:56 +02:00
|
|
|
'video-embed': './src/standalone/videos/embed.ts',
|
|
|
|
'player': './src/standalone/player/player.ts',
|
|
|
|
'test-embed': './src/standalone/videos/test-embed.ts'
|
2017-07-23 14:49:52 +02: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' ],
|
|
|
|
|
2018-06-07 16:50:33 +02:00
|
|
|
modules: [ helpers.root('src'), helpers.root('node_modules') ],
|
|
|
|
|
|
|
|
alias: {
|
2020-07-02 16:30:33 +02:00
|
|
|
'video.js$': path.resolve('node_modules/video.js/core.js'),
|
2020-08-03 18:06:49 +02:00
|
|
|
'@root-helpers': path.resolve('src/root-helpers'),
|
2020-06-26 08:37:26 +02:00
|
|
|
'@shared/models': path.resolve('../shared/models'),
|
2020-08-06 14:58:01 +02:00
|
|
|
'@shared/core-utils': path.resolve('../shared/core-utils')
|
2018-06-07 16:50:33 +02:00
|
|
|
}
|
2017-07-23 14:49:52 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: helpers.root('dist/standalone/videos'),
|
2020-08-06 10:26:39 +02:00
|
|
|
|
|
|
|
filename: process.env.ANALYZE_BUNDLE === 'true'
|
|
|
|
? '[name].bundle.js'
|
|
|
|
: '[name].[hash].bundle.js',
|
|
|
|
|
2017-07-23 14:49:52 +02:00
|
|
|
sourceMapFilename: '[file].map',
|
2020-08-06 10:26:39 +02:00
|
|
|
chunkFilename: '[id].[hash].chunk.js',
|
2017-07-23 14:49:52 +02:00
|
|
|
publicPath: '/client/standalone/videos/'
|
|
|
|
},
|
|
|
|
|
2018-09-21 14:08:14 +02:00
|
|
|
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
|
2018-05-29 15:05:03 +02:00
|
|
|
|
2017-07-23 14:49:52 +02:00
|
|
|
module: {
|
|
|
|
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
use: [
|
|
|
|
{
|
2020-06-26 08:37:26 +02:00
|
|
|
loader: 'ts-loader',
|
2017-07-23 14:49:52 +02:00
|
|
|
options: {
|
2020-06-26 08:37:26 +02:00
|
|
|
configFile: 'tsconfig.base.json'
|
2017-07-23 14:49:52 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-26 08:37:26 +02:00
|
|
|
]
|
2017-07-23 14:49:52 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.(sass|scss)$/,
|
2020-11-19 11:12:01 +01:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
importLoaders: 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sassOptions: {
|
2017-07-23 14:49:52 +02:00
|
|
|
sourceMap: true,
|
2020-11-19 11:12:01 +01:00
|
|
|
includePaths: [
|
|
|
|
helpers.root('src/sass/include')
|
|
|
|
]
|
2017-07-23 14:49:52 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-19 11:12:01 +01:00
|
|
|
}
|
|
|
|
]
|
2017-07-23 14:49:52 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
use: 'raw-loader',
|
|
|
|
exclude: [
|
|
|
|
helpers.root('src/index.html'),
|
2018-07-10 17:47:56 +02:00
|
|
|
helpers.root('src/standalone/videos/embed.html'),
|
|
|
|
helpers.root('src/standalone/videos/test-embed.html')
|
2017-07-23 14:49:52 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png|gif)$/,
|
|
|
|
use: 'url-loader'
|
|
|
|
},
|
|
|
|
|
|
|
|
{ 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' }
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
2020-11-19 11:12:01 +01:00
|
|
|
new MiniCssExtractPlugin({
|
2020-08-06 10:26:39 +02:00
|
|
|
filename: process.env.ANALYZE_BUNDLE === 'true'
|
|
|
|
? '[name].css'
|
|
|
|
: '[name].[hash].css'
|
2017-07-23 14:49:52 +02:00
|
|
|
}),
|
|
|
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: 'src/standalone/videos/embed.html',
|
|
|
|
filename: 'embed.html',
|
|
|
|
title: 'PeerTube',
|
2020-03-31 15:43:17 +02:00
|
|
|
chunksSortMode: 'auto',
|
2018-07-10 17:47:56 +02:00
|
|
|
inject: 'body',
|
2020-12-08 14:51:51 +01:00
|
|
|
chunks: ['video-embed'],
|
|
|
|
minify: {
|
|
|
|
collapseWhitespace: true,
|
|
|
|
removeComments: false,
|
|
|
|
removeRedundantAttributes: true,
|
|
|
|
removeScriptTypeAttributes: true,
|
|
|
|
removeStyleLinkTypeAttributes: true,
|
|
|
|
useShortDoctype: true
|
|
|
|
}
|
2018-07-10 17:47:56 +02:00
|
|
|
}),
|
|
|
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: '!!html-loader!src/standalone/videos/test-embed.html',
|
|
|
|
filename: 'test-embed.html',
|
|
|
|
title: 'PeerTube',
|
2020-03-31 15:43:17 +02:00
|
|
|
chunksSortMode: 'auto',
|
2018-07-10 17:47:56 +02:00
|
|
|
inject: 'body',
|
|
|
|
chunks: ['test-embed']
|
2017-12-12 11:38:02 +01:00
|
|
|
}),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plugin LoaderOptionsPlugin (experimental)
|
|
|
|
*
|
|
|
|
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
|
|
|
|
*/
|
|
|
|
new LoaderOptionsPlugin({
|
|
|
|
options: {
|
|
|
|
context: __dirname,
|
|
|
|
output: {
|
|
|
|
path: helpers.root('dist')
|
|
|
|
}
|
|
|
|
}
|
2017-07-23 14:49:52 +02:00
|
|
|
})
|
|
|
|
],
|
|
|
|
|
2018-09-21 09:18:28 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-04-06 16:06:43 +02:00
|
|
|
performance: {
|
2018-05-14 10:57:07 +02:00
|
|
|
maxEntrypointSize: 700000, // 600kB
|
|
|
|
maxAssetSize: 700000
|
2018-04-06 16:06:43 +02:00
|
|
|
},
|
|
|
|
|
2017-07-23 14:49:52 +02:00
|
|
|
node: {
|
|
|
|
global: true,
|
|
|
|
crypto: 'empty',
|
|
|
|
fs: 'empty',
|
|
|
|
process: true,
|
|
|
|
module: false,
|
|
|
|
clearImmediate: false,
|
|
|
|
setImmediate: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return configuration
|
|
|
|
}
|