Skip to content

Commit 01baf4a

Browse files
committed
fix: move to using a root vitest config
We were quickly going to end up with too many sub-configs, and all sorts of problems with extending the various configs. This switches to a single root config which globs each of the monorepo packages instead.
1 parent 7639e98 commit 01baf4a

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

vitest.config.mjs

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
11
import { defineConfig } from 'vitest/config';
2+
import { manglePlugin } from './scripts/mangle-plugin.mjs';
3+
import path from 'node:path';
4+
import { fileURLToPath } from 'node:url';
25

6+
const MINIFY = process.env.MINIFY === "true";
37
const COVERAGE = process.env.COVERAGE === 'true';
8+
const dirname = path.dirname(fileURLToPath(import.meta.url));
49

510
export default defineConfig({
11+
resolve: {
12+
alias: MINIFY ? {
13+
'@preact/signals-core': path.join(
14+
dirname, './packages/core/dist/signals-core.min.js'
15+
),
16+
'@preact/signals': path.join(
17+
dirname, './packages/preact/dist/signals.min.js'
18+
),
19+
'@preact/signals-react': path.join(
20+
dirname, './packages/react/dist/signals.min.js'
21+
),
22+
'@preact/signals-react-utils': path.join(
23+
dirname, './packages/react/utils/utils.min.js'
24+
),
25+
'@preact/signals-react-transform': path.join(
26+
dirname ,'./packages/react-transform/dist/signals-transform.mjs'
27+
),
28+
'@preact/signals-utils': path.join(
29+
dirname, './packages/preact/utils/dist/utils.min.js'
30+
),
31+
} : {}
32+
},
33+
plugins: [
34+
manglePlugin
35+
],
636
test: {
737
coverage: {
838
enabled: COVERAGE,
@@ -15,8 +45,28 @@ export default defineConfig({
1545
reportsDirectory: './coverage'
1646
},
1747
projects: [
18-
'packages/*/vitest.config.mjs',
19-
'packages/*/vitest.browser.config.mjs'
48+
{
49+
extends: true,
50+
test: {
51+
include: [
52+
'./packages/{}/test/**/*.test.tsx',
53+
'!./packages/{}/test/browser/**/*.test.tsx'
54+
],
55+
}
56+
},
57+
{
58+
extends: true,
59+
test: {
60+
include: ['./packages/{}/test/browser/**/*.test.tsx'],
61+
browser: {
62+
provider: 'playwright',
63+
enabled: true,
64+
screenshotFailures: false,
65+
headless: true,
66+
instances: [{ browser: 'chromium' }]
67+
}
68+
}
69+
}
2070
]
2171
}
2272
});

0 commit comments

Comments
 (0)