-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
86 lines (84 loc) · 2.8 KB
/
vite.config.ts
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
import * as path from "node:path";
import { defineConfig } from "vite";
import type { UserConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { configDefaults } from "vitest/config";
import type { UserConfig as VitestConfig } from "vitest/config";
import istanbul from "vite-plugin-istanbul";
// import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
// import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
// You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
// import rollupNodePolyFills from "rollup-plugin-node-polyfills";
// import { visualizer } from 'rollup-plugin-visualizer';
// https://vitejs.dev/config/
const config: UserConfig & { test: VitestConfig["test"] } = {
build: {
target: "es6",
},
plugins: [
svelte(),
istanbul({
cypress: true,
requireEnv: false,
nycrcPath: "./.nycrc.json",
forceBuildInstrument: true, // Instrument the source code for cypress runs
}),
// , visualizer()
],
// build: {
// rollupOptions: {
// external: [
// "@vearnfi/config",
// "@vearnfi/wrapped-connex",
// // ^ Required while linking local packages.
// ],
// },
// },
resolve: {
alias: {
"@": path.resolve("./src"),
// This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill,
// see https://github.com/remorses/esbuild-plugins/blob/master/node-modules-polyfill/src/polyfills.ts
// process and buffer are excluded because already managed
// by node-globals-polyfill
// "./runtimeConfig": "./runtimeConfig.browser",
// buffer: "rollup-plugin-node-polyfills/polyfills/buffer-es6",
crypto: "crypto-browserify",
},
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: "globalThis",
},
// Enable esbuild polyfill plugins
// plugins: [
// NodeGlobalsPolyfillPlugin({
// process: true,
// buffer: true,
// }),
// NodeModulesPolyfillPlugin(),
// ],
},
},
test: {
// jest like globals
globals: true,
environment: "jsdom",
// Add @testing-library/jest-dom matchers & mocks of SvelteKit modules
setupFiles: ["./setupTest.ts"],
// Exclude files in v8
coverage: {
provider: "istanbul",
// you can include other reporters, but 'json-summary' is required, json is recommended
reporter: ["text", "json-summary", "json", "lcov"],
reportsDirectory: "./unit-coverage",
all: true,
include: ["src/**/*.{ts,svelte}", "!src/tests"],
},
// Exclude playwright tests folder
exclude: [...configDefaults.exclude, "tests"],
},
};
export default defineConfig(config);