-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathvite.config.js
More file actions
87 lines (85 loc) · 2.06 KB
/
vite.config.js
File metadata and controls
87 lines (85 loc) · 2.06 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { nodeExternals } from "rollup-plugin-node-externals";
import typescript from "@rollup/plugin-typescript";
import { playwright } from "@vitest/browser-playwright";
const isCI = !!process.env.CI;
export default defineConfig({
plugins: [
react(),
nodeExternals({
// Externalize peer dependencies but bundle makeup-js libraries
include: [/^makeup-/],
}),
],
build: {
lib: {
entry: "./src/index.ts",
formats: ["es"],
},
rollupOptions: {
output: {
preserveModules: true,
preserveModulesRoot: "src",
entryFileNames: "[name].js",
banner: `"use client";\n`,
},
plugins: [
typescript({
// We use a different tsconfig for building so vite doesn't generate types for tests,
// but we still want to have typescript checking for test files.
tsconfig: "./tsconfig.prod.json",
declaration: true,
declarationMap: true,
outDir: "./dist",
}),
],
},
sourcemap: true,
minify: false,
target: "es2020",
},
test: {
globals: true,
pool: "forks",
coverage: {
enabled: isCI,
provider: "v8",
reporter: ["json-summary", "html", "cobertura", "lcov"],
include: ["src/**/*.{ts,tsx}"],
exclude: [
"src/**/test/**",
"src/**/*.stories.tsx",
"src/**/*.d.ts",
"src/index.ts",
],
},
projects: [
{
extends: true,
test: {
name: "browser",
browser: {
enabled: true,
provider: playwright(),
headless: true,
instances: [
{
browser: "chromium",
},
],
},
include: ["src/**/test.browser.{ts,tsx}"],
},
},
{
extends: true,
test: {
name: "server",
environment: "node",
include: ["src/**/test.server.{ts,tsx}"],
},
},
],
},
});