mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 09:21:21 +01:00
fe8a9ce31d
Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com> Co-authored-by: Dominic Gannaway <dg@domgan.com>
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
import { configDefaults, defineConfig } from 'vitest/config';
|
|
|
|
const pkg = JSON.parse(fs.readFileSync('packages/svelte/package.json', 'utf8'));
|
|
|
|
export default defineConfig({
|
|
// We need both a plugin and an alias for some reason
|
|
resolve: {
|
|
alias: [
|
|
{
|
|
find: /^svelte\/?/,
|
|
customResolver: (id) => {
|
|
// For some reason this turns up as "undefined" instead of "svelte"
|
|
const exported = pkg.exports[id.replace('undefined', '.')];
|
|
if (!exported) return;
|
|
|
|
return path.resolve('packages/svelte', exported.browser ?? exported.default);
|
|
}
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
{
|
|
name: 'resolve-svelte',
|
|
resolveId(id) {
|
|
if (/^svelte\/?/.test(id)) {
|
|
const exported = pkg.exports[id.replace('svelte', '.')];
|
|
if (!exported) return;
|
|
|
|
return path.resolve('packages/svelte', exported.browser ?? exported.default);
|
|
}
|
|
}
|
|
}
|
|
],
|
|
test: {
|
|
dir: '.',
|
|
reporters: ['dot'],
|
|
include: [
|
|
'packages/svelte/tests/*/test.ts',
|
|
'packages/svelte/tests/runtime-browser/test-ssr.ts'
|
|
],
|
|
exclude: [...configDefaults.exclude, '**/samples/**'],
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['lcov', 'html']
|
|
}
|
|
}
|
|
});
|