2020-05-04 12:44:12 +02:00
|
|
|
const path = require('path');
|
2020-08-15 12:44:52 +02:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2020-08-16 20:24:45 +02:00
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
2020-11-19 23:36:35 -05:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2021-10-05 00:26:00 -04:00
|
|
|
const { DefinePlugin } = require('webpack');
|
2020-05-29 23:32:45 +02:00
|
|
|
|
2020-11-21 04:07:37 +01:00
|
|
|
const Assets = [
|
|
|
|
'native-promise-only/npo.js',
|
|
|
|
'libarchive.js/dist/worker-bundle.js',
|
2022-05-16 01:50:01 +03:00
|
|
|
'@jellyfin/libass-wasm/dist/js/subtitles-octopus-worker.js',
|
|
|
|
'@jellyfin/libass-wasm/dist/js/subtitles-octopus-worker.data',
|
|
|
|
'@jellyfin/libass-wasm/dist/js/subtitles-octopus-worker.wasm',
|
|
|
|
'@jellyfin/libass-wasm/dist/js/subtitles-octopus-worker-legacy.js',
|
|
|
|
'@jellyfin/libass-wasm/dist/js/subtitles-octopus-worker-legacy.data',
|
|
|
|
'@jellyfin/libass-wasm/dist/js/subtitles-octopus-worker-legacy.js.mem',
|
2020-11-21 04:07:37 +01:00
|
|
|
'pdfjs-dist/build/pdf.worker.js'
|
|
|
|
];
|
|
|
|
|
|
|
|
const LibarchiveWasm = [
|
|
|
|
'libarchive.js/dist/wasm-gen/libarchive.js',
|
|
|
|
'libarchive.js/dist/wasm-gen/libarchive.wasm'
|
|
|
|
];
|
|
|
|
|
2019-04-28 11:38:30 +01:00
|
|
|
module.exports = {
|
2020-05-04 12:44:12 +02:00
|
|
|
context: path.resolve(__dirname, 'src'),
|
2020-11-27 19:17:04 +03:00
|
|
|
target: 'browserslist',
|
2019-04-28 11:38:30 +01:00
|
|
|
resolve: {
|
2021-06-11 14:49:57 +02:00
|
|
|
extensions: ['.tsx', '.ts', '.js'],
|
2019-04-28 11:38:30 +01:00
|
|
|
modules: [
|
2020-05-04 12:44:12 +02:00
|
|
|
path.resolve(__dirname, 'node_modules')
|
2019-04-28 11:38:30 +01:00
|
|
|
]
|
2019-05-25 00:28:06 -04:00
|
|
|
},
|
2019-10-01 02:58:05 +03:00
|
|
|
plugins: [
|
2021-10-05 00:26:00 -04:00
|
|
|
new DefinePlugin({
|
|
|
|
__WEBPACK_SERVE__: JSON.stringify(!!process.env.WEBPACK_SERVE)
|
|
|
|
}),
|
2020-08-16 20:24:45 +02:00
|
|
|
new CleanWebpackPlugin(),
|
2020-11-19 23:36:35 -05:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: 'index.html',
|
2021-07-14 15:33:30 -04:00
|
|
|
template: 'index.html',
|
|
|
|
// Append file hashes to bundle urls for cache busting
|
|
|
|
hash: true
|
2020-11-19 23:36:35 -05:00
|
|
|
}),
|
2020-08-16 20:24:45 +02:00
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: 'themes/',
|
|
|
|
to: 'themes/'
|
2020-10-22 01:10:40 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'assets/**',
|
|
|
|
globOptions: {
|
2021-03-06 12:52:49 +03:00
|
|
|
dot: true,
|
2020-10-22 01:10:40 +01:00
|
|
|
ignore: ['**/css/*']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2021-03-06 12:51:55 +03:00
|
|
|
from: '*.*',
|
2020-10-22 01:10:40 +01:00
|
|
|
globOptions: {
|
2021-03-06 12:52:49 +03:00
|
|
|
dot: true,
|
2020-10-22 01:10:40 +01:00
|
|
|
ignore: ['**.js', '**.html']
|
|
|
|
}
|
2020-08-16 20:24:45 +02:00
|
|
|
}
|
|
|
|
]
|
2020-11-09 19:20:55 +00:00
|
|
|
}),
|
2020-11-21 04:07:37 +01:00
|
|
|
new CopyPlugin({
|
|
|
|
patterns: Assets.map(asset => {
|
|
|
|
return {
|
|
|
|
from: path.resolve(__dirname, `./node_modules/${asset}`),
|
|
|
|
to: path.resolve(__dirname, './dist/libraries')
|
|
|
|
};
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: LibarchiveWasm.map(asset => {
|
|
|
|
return {
|
|
|
|
from: path.resolve(__dirname, `./node_modules/${asset}`),
|
|
|
|
to: path.resolve(__dirname, './dist/libraries/wasm-gen')
|
|
|
|
};
|
|
|
|
})
|
2020-08-16 20:24:45 +02:00
|
|
|
})
|
2020-08-15 12:44:52 +02:00
|
|
|
],
|
|
|
|
output: {
|
2021-08-05 22:10:36 +02:00
|
|
|
filename: '[name].jellyfin.bundle.js',
|
2021-07-14 15:33:30 -04:00
|
|
|
chunkFilename: '[name].[contenthash].chunk.js',
|
2021-02-27 12:59:29 +03:00
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
publicPath: ''
|
2020-10-18 15:29:40 +01:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
2020-10-18 20:37:54 +01:00
|
|
|
{
|
|
|
|
test: /\.(html)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'html-loader'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2021-06-11 14:49:57 +02:00
|
|
|
test: /\.(js|jsx)$/,
|
2023-02-14 23:01:00 +03:00
|
|
|
include: [
|
2023-02-14 23:01:30 +03:00
|
|
|
path.resolve(__dirname, 'node_modules/@jellyfin/libass-wasm'),
|
2023-02-14 23:01:00 +03:00
|
|
|
path.resolve(__dirname, 'node_modules/@uupaa/dynamic-import-polyfill'),
|
|
|
|
path.resolve(__dirname, 'node_modules/blurhash'),
|
|
|
|
path.resolve(__dirname, 'node_modules/date-fns'),
|
|
|
|
path.resolve(__dirname, 'node_modules/epubjs'),
|
|
|
|
path.resolve(__dirname, 'node_modules/flv.js'),
|
|
|
|
path.resolve(__dirname, 'node_modules/libarchive.js'),
|
|
|
|
path.resolve(__dirname, 'node_modules/marked'),
|
|
|
|
path.resolve(__dirname, 'node_modules/screenfull'),
|
|
|
|
path.resolve(__dirname, 'src')
|
|
|
|
],
|
2020-10-18 20:37:54 +01:00
|
|
|
use: [{
|
2020-12-04 00:49:37 +03:00
|
|
|
loader: 'babel-loader'
|
2020-10-18 20:37:54 +01:00
|
|
|
}]
|
|
|
|
},
|
2021-12-31 00:04:12 +03:00
|
|
|
{
|
|
|
|
test: /\.worker\.ts$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
|
|
|
'worker-loader',
|
|
|
|
'ts-loader'
|
|
|
|
]
|
|
|
|
},
|
2021-06-11 14:49:57 +02:00
|
|
|
{
|
|
|
|
test: /\.(ts|tsx)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [{
|
|
|
|
loader: 'ts-loader'
|
|
|
|
}]
|
|
|
|
},
|
2020-11-28 01:46:16 +03:00
|
|
|
/* modules that Babel breaks when transforming to ESM */
|
|
|
|
{
|
2023-02-14 23:01:00 +03:00
|
|
|
test: /\.js$/,
|
|
|
|
include: [
|
|
|
|
path.resolve(__dirname, 'node_modules/pdfjs-dist'),
|
|
|
|
path.resolve(__dirname, 'node_modules/xmldom')
|
|
|
|
],
|
2020-11-28 01:46:16 +03:00
|
|
|
use: [{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
plugins: [
|
|
|
|
'@babel/transform-modules-umd'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
2020-11-06 00:00:34 +00:00
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/i,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
2021-06-15 01:05:47 -04:00
|
|
|
postcssOptions: {
|
|
|
|
config: path.resolve(__dirname, 'postcss.config.js')
|
2020-11-06 00:00:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'sass-loader'
|
|
|
|
]
|
|
|
|
},
|
2020-10-18 20:37:54 +01:00
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
2021-06-15 01:05:47 -04:00
|
|
|
postcssOptions: {
|
|
|
|
config: path.resolve(__dirname, 'postcss.config.js')
|
2020-10-18 20:37:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|gif|svg)$/i,
|
2021-10-23 01:24:14 -04:00
|
|
|
type: 'asset/resource'
|
2020-10-18 20:37:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
2021-10-23 01:24:14 -04:00
|
|
|
type: 'asset/resource'
|
2020-10-18 20:37:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(mp3)$/i,
|
2021-10-23 01:24:14 -04:00
|
|
|
type: 'asset/resource'
|
2020-10-18 20:37:54 +01:00
|
|
|
},
|
2020-10-18 15:29:40 +01:00
|
|
|
{
|
|
|
|
test: require.resolve('jquery'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: ['$', 'jQuery']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-08-15 12:44:52 +02:00
|
|
|
}
|
2019-05-22 15:18:17 -04:00
|
|
|
};
|