1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Split node_modules to separate bundles

This commit is contained in:
Bill Thornton 2022-09-06 01:45:59 -04:00
parent 413c6f537a
commit e4a2d7513b
3 changed files with 21 additions and 3 deletions

View file

@ -81,11 +81,29 @@ module.exports = {
}) })
], ],
output: { output: {
filename: '[name].jellyfin.bundle.js', filename: '[name].bundle.js',
chunkFilename: '[name].[contenthash].chunk.js', chunkFilename: '[name].[contenthash].chunk.js',
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
publicPath: '' publicPath: ''
}, },
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `node_modules.${packageName}`;
}
}
}
}
},
module: { module: {
rules: [ rules: [
{ {

View file

@ -5,7 +5,7 @@ module.exports = merge(common, {
// In order for live reload to work we must use "web" as the target not "browserslist" // In order for live reload to work we must use "web" as the target not "browserslist"
target: process.env.WEBPACK_SERVE ? 'web' : 'browserslist', target: process.env.WEBPACK_SERVE ? 'web' : 'browserslist',
mode: 'development', mode: 'development',
entry: './scripts/site.js', entry: { 'main.jellyfin': './scripts/site.js' },
devtool: 'source-map', devtool: 'source-map',
module: { module: {
rules: [ rules: [

View file

@ -5,7 +5,7 @@ const WorkboxPlugin = require('workbox-webpack-plugin');
module.exports = merge(common, { module.exports = merge(common, {
mode: 'production', mode: 'production',
entry: './scripts/site.js', entry: { 'main.jellyfin': './scripts/site.js' },
plugins: [ plugins: [
new WorkboxPlugin.InjectManifest({ new WorkboxPlugin.InjectManifest({
swSrc: path.resolve(__dirname, 'src/serviceworker.js'), swSrc: path.resolve(__dirname, 'src/serviceworker.js'),