2023-07-19 09:42:47 +00:00
|
|
|
import { sveltekit } from '@sveltejs/kit/vite';
|
2023-07-22 07:29:40 +00:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import * as fs from 'fs';
|
|
|
|
import { resolve } from 'path';
|
2023-07-19 09:42:47 +00:00
|
|
|
|
|
|
|
export default defineConfig({
|
2023-07-22 07:29:40 +00:00
|
|
|
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}']
|
|
|
|
}
|
|
|
|
});
|