mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2025-01-08 14:31:55 +00:00
826c367442
Workaround sourced from https://github.com/vitejs/vite/issues/15153 Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
139 lines
3.7 KiB
TypeScript
139 lines
3.7 KiB
TypeScript
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
|
import virtual from '@rollup/plugin-virtual';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import browserslist from 'browserslist';
|
|
import { browserslistToTargets } from 'lightningcss';
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
import IconsResolver from 'unplugin-icons/resolver';
|
|
import Icons from 'unplugin-icons/vite';
|
|
import {
|
|
Vuetify3Resolver,
|
|
VueUseComponentsResolver,
|
|
VueUseDirectiveResolver
|
|
} from 'unplugin-vue-components/resolvers';
|
|
import Components from 'unplugin-vue-components/vite';
|
|
import VueRouter from 'unplugin-vue-router/vite';
|
|
import { defineConfig, UserConfig } from 'vite';
|
|
import { entrypoints, localeFilesFolder, srcRoot } from './scripts/paths';
|
|
import virtualModules from './scripts/virtual-modules';
|
|
|
|
export default defineConfig(({ mode }): UserConfig => {
|
|
const config: UserConfig = {
|
|
appType: 'spa',
|
|
base: './',
|
|
cacheDir: '../node_modules/.cache/vite',
|
|
plugins: [
|
|
virtual(virtualModules),
|
|
VueRouter({
|
|
dts: './types/global/routes.d.ts',
|
|
importMode: 'sync',
|
|
routeBlockLang: 'yaml'
|
|
}),
|
|
vue(),
|
|
// This plugin allows to autoimport vue components
|
|
Components({
|
|
dts: './types/global/components.d.ts',
|
|
/**
|
|
* The icons resolver finds icons components from 'unplugin-icons' using this convenction:
|
|
* {prefix}-{collection}-{icon} e.g. <i-mdi-thumb-up />
|
|
*/
|
|
resolvers: [
|
|
IconsResolver(),
|
|
VueUseComponentsResolver(),
|
|
Vuetify3Resolver(),
|
|
VueUseDirectiveResolver()
|
|
]
|
|
}),
|
|
/**
|
|
* This plugin allows to use all icons from Iconify as vue components
|
|
* See: https://github.com/antfu/unplugin-icons
|
|
*/
|
|
Icons({
|
|
compiler: 'vue3'
|
|
}),
|
|
VueI18nPlugin({
|
|
runtimeOnly: true,
|
|
compositionOnly: true,
|
|
fullInstall: false,
|
|
forceStringify: true,
|
|
include: localeFilesFolder
|
|
})
|
|
],
|
|
build: {
|
|
/**
|
|
* See main.ts for an explanation of this target
|
|
*/
|
|
target: 'es2022',
|
|
cssCodeSplit: false,
|
|
cssMinify: 'lightningcss',
|
|
modulePreload: false,
|
|
reportCompressedSize: false,
|
|
rollupOptions: {
|
|
input: {
|
|
splashscreen: entrypoints.splashscreen,
|
|
main: entrypoints.main,
|
|
index: entrypoints.index
|
|
},
|
|
output: {
|
|
validate: true,
|
|
plugins: [
|
|
mode === 'analyze'
|
|
?
|
|
visualizer({
|
|
open: true,
|
|
filename: 'dist/stats.html',
|
|
gzipSize: true,
|
|
brotliSize: true
|
|
})
|
|
: undefined
|
|
]
|
|
/**
|
|
* TODO: Revisit after the following issues are fixed:
|
|
* - https://github.com/vitejs/vite/issues/5142
|
|
* - https://github.com/evanw/esbuild/issues/399
|
|
* - https://github.com/rollup/rollup/issues/3888
|
|
*/
|
|
/*
|
|
* manualChunks(id) {
|
|
* if (
|
|
* id.includes('virtual:locales') ||
|
|
* id.includes('@intlify/unplugin-vue-i18n/messages')
|
|
* ) {
|
|
* return 'localization';
|
|
* }
|
|
* }
|
|
*/
|
|
}
|
|
}
|
|
},
|
|
css: {
|
|
lightningcss: {
|
|
nonStandard: {
|
|
deepSelectorCombinator: true
|
|
},
|
|
targets: browserslistToTargets(browserslist())
|
|
}
|
|
},
|
|
preview: {
|
|
port: 3000,
|
|
strictPort: true,
|
|
host: '0.0.0.0',
|
|
cors: true
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 3000
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@/': srcRoot
|
|
}
|
|
},
|
|
worker: {
|
|
format: 'es'
|
|
}
|
|
};
|
|
|
|
return config;
|
|
});
|