-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
62 lines (59 loc) · 1.58 KB
/
vite.config.ts
File metadata and controls
62 lines (59 loc) · 1.58 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
/// <reference types="vitest/config" />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import dts from "vite-plugin-dts";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
/**
* Configuration
*/
const LIBRARY_NAME = "react-library-template";
/**
* Directory
*/
const __dirname = dirname(fileURLToPath(import.meta.url));
export default defineConfig(() => ({
root: __dirname,
cacheDir: `./node_modules/.vite/${LIBRARY_NAME}`,
plugins: [
react(),
dts({
rollupTypes: true,
entryRoot: "src",
tsconfigPath: resolve(__dirname, "tsconfig.lib.json"),
}),
],
build: {
outDir: "dist",
emptyOutDir: true,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
lib: {
// Could also be a dictionary or array of multiple entry points.
// See output formats for single/multiple entry points: http://vite.dev/guide/build.html#library-mode
entry: "./src/lib/index.ts",
name: LIBRARY_NAME,
fileName: "index",
// Change this to the formats you want to support.
// Don't forget to update your package.json as well.
formats: ["es" as const],
},
rollupOptions: {
// External packages that should not be bundled into your library.
external: ["react", "react-dom", "react/jsx-runtime"],
},
},
test: {
watch: false,
globals: true,
environment: "jsdom",
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
reporters: ["default"],
coverage: {
reportsDirectory: `./coverage/${LIBRARY_NAME}`,
provider: "v8" as const,
},
},
}));