forked from immerjs/immer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.build.ts
More file actions
59 lines (57 loc) · 1.46 KB
/
vitest.config.build.ts
File metadata and controls
59 lines (57 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import {defineConfig} from "vitest/config"
import path from "path"
const prodCJSPath = path.resolve(__dirname, "dist/cjs/immer.cjs.production.js")
export default defineConfig({
resolve: {
// // Make all `immer` imports use the production build
alias: [
{
find: /^src\/(.*)/,
replacement: prodCJSPath
},
{
find: "../src/immer",
replacement: prodCJSPath
},
{
find: "immer",
replacement: prodCJSPath
}
],
// Ensure only one copy of immer is used throughout the dependency tree
dedupe: ["immer"]
},
// Force Vite to process immer so our alias applies to dependencies too
optimizeDeps: {
include: ["immer"],
// Force re-bundling to pick up our alias
force: true
},
// SSR settings are needed because Vitest runs in Node environment
ssr: {
// Don't externalize immer - this makes our alias apply to it
noExternal: ["immer"]
},
define: {
"global.USES_BUILD": true,
"process.env.NODE_ENV": '"production"'
},
test: {
environment: "node",
include: ["**/__tests__/**/*.[jt]s?(x)"],
globals: true,
resolveSnapshotPath: (testPath: string, snapExtension: string) =>
testPath.replace("__tests__", "__tests__/__prod_snapshots__") +
snapExtension,
reporters: ["default", "./vitest-custom-reporter.ts"],
// Ensure deps are processed through Vite's transform pipeline
deps: {
optimizer: {
// For SSR (Node) environment, include immer so it's transformed
ssr: {
include: ["immer"]
}
}
}
}
})