auth.andert.me/vite.config.ts

32 lines
768 B
TypeScript
Raw Normal View History

2023-07-19 09:42:47 +00:00
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import * as fs from 'fs';
import { resolve } from 'path';
2023-07-19 09:42:47 +00:00
export default defineConfig({
plugins: [
sveltekit(),
{
name: 'components-resolver',
resolveId(source) {
if (source === 'virtual:components-list') return source;
return null;
},
load(id) {
if (id === 'virtual:components-list') {
const componentsDir = resolve(__dirname, 'src/lib/components');
const components = fs.readdirSync(componentsDir)
.filter(f => f.endsWith('.svelte'))
.map(f => f.replace('.svelte', ''));
return `export default ${JSON.stringify(components)};`;
}
return null;
}
}
],
2023-07-19 09:42:47 +00:00
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
});