mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2025-06-16 12:13:09 +00:00
* The dpdm dependency was used just for checking circular dependencies in the bundle. However, it was not perfect, not analyzing the real bundle, but the source files. We were just leveraging Rollup's (Vite internal bundler) warnings for that already when analyzing the bundle, which always gave us the real information. Now, `analyze` consists in 2 different commands (analyze:bundle for the bundle and analyze:cycles for finding cycles) * The npm commands have been grouped by scope * Extracted analyze Vite commands to a plugin, so the main config is cleaner. Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { visualizer } from 'rollup-plugin-visualizer';
|
|
import type { RollupLog } from 'rollup';
|
|
import type { Plugin } from 'vite';
|
|
|
|
/**
|
|
* This plugin extracts the logic for the analyze commands, so the main Vite config is cleaner.
|
|
*/
|
|
export function JellyfinVueAnalysis(): Plugin {
|
|
const warnings: RollupLog[] = [];
|
|
|
|
return {
|
|
name: 'Jellyfin_Vue:analysis',
|
|
enforce: 'post',
|
|
config: (_, env) => {
|
|
if (env.mode === 'analyze:bundle') {
|
|
return {
|
|
build: {
|
|
rollupOptions: {
|
|
plugins: [
|
|
visualizer({
|
|
open: true,
|
|
filename: 'dist/stats.html'
|
|
})
|
|
]
|
|
}
|
|
}
|
|
};
|
|
} else if (env.mode === 'analyze:cycles') {
|
|
return {
|
|
build: {
|
|
rollupOptions: {
|
|
onwarn: (warning) => {
|
|
if (warning.code === 'CIRCULAR_DEPENDENCY') {
|
|
warnings.push(warning);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
},
|
|
closeBundle: () => {
|
|
if (warnings.length > 0) {
|
|
for (const warning of warnings) {
|
|
console.warn(warning);
|
|
}
|
|
|
|
throw new Error('There are circular dependencies');
|
|
}
|
|
}
|
|
};
|
|
}
|