|
1 | | -import react from '@vitejs/plugin-react'; |
2 | | -import path from 'node:path'; |
3 | | -import { fileURLToPath } from 'node:url'; |
4 | | -import { defineConfig } from 'vite'; |
5 | | -import dts from 'vite-plugin-dts'; |
| 1 | +import react from "@vitejs/plugin-react"; |
| 2 | +import path from "node:path"; |
| 3 | +import { fileURLToPath } from "node:url"; |
| 4 | +import { defineConfig } from "vite"; |
| 5 | +import dts from "vite-plugin-dts"; |
6 | 6 |
|
7 | | -import pkg from './package.json'; |
| 7 | +import pkg from "./package.json"; |
8 | 8 |
|
9 | 9 | export default defineConfig({ |
10 | 10 | plugins: [ |
11 | 11 | react(), |
12 | 12 | dts({ |
13 | | - exclude: ['**/*.test.{ts,tsx}', '**/*.stories.{ts,tsx}'], |
14 | | - entryRoot: 'src', |
15 | | - outDir: 'dist/types', |
16 | | - tsconfigPath: './tsconfig.build.json' |
17 | | - }) |
| 13 | + exclude: ["**/*.test.{ts,tsx}", "**/*.stories.{ts,tsx}"], |
| 14 | + entryRoot: "src", |
| 15 | + outDir: "dist/types", |
| 16 | + tsconfigPath: "./tsconfig.build.json", |
| 17 | + }), |
18 | 18 | ], |
19 | 19 | resolve: { |
20 | 20 | alias: { |
21 | | - '@': fileURLToPath(new URL('./src', import.meta.url)) |
22 | | - } |
| 21 | + "@": fileURLToPath(new URL("./src", import.meta.url)), |
| 22 | + }, |
23 | 23 | }, |
24 | 24 | build: { |
25 | 25 | lib: { |
26 | | - entry: path.resolve(__dirname, 'src/index.ts'), |
| 26 | + entry: path.resolve(__dirname, "src/index.ts"), |
27 | 27 | name: pkg.name, |
28 | | - fileName: (format) => `index.${format}.js` |
| 28 | + fileName: (format) => `index.${format}.js`, |
29 | 29 | }, |
30 | 30 | rollupOptions: { |
31 | 31 | input: { |
32 | | - index: path.resolve(__dirname, 'src/index.ts') |
| 32 | + index: path.resolve(__dirname, "src/index.ts"), |
33 | 33 | }, |
34 | 34 | external: [ |
35 | 35 | ...Object.keys(pkg.dependencies || {}), |
36 | 36 | ...Object.keys(pkg.peerDependencies || {}), |
37 | | - 'react/jsx-runtime' |
| 37 | + "react/jsx-runtime", |
38 | 38 | ], |
39 | 39 | output: [ |
40 | 40 | { |
41 | | - format: 'es', |
42 | | - dir: 'dist/esm', |
| 41 | + format: "es", |
| 42 | + dir: "dist/esm", |
43 | 43 | preserveModules: true, |
44 | | - preserveModulesRoot: 'src', |
45 | | - entryFileNames: '[name].mjs' |
| 44 | + preserveModulesRoot: "src", |
| 45 | + entryFileNames: "[name].mjs", |
46 | 46 | }, |
47 | 47 | { |
48 | | - format: 'cjs', |
49 | | - dir: 'dist/cjs', |
| 48 | + format: "cjs", |
| 49 | + dir: "dist/cjs", |
50 | 50 | preserveModules: true, |
51 | | - preserveModulesRoot: 'src', |
52 | | - entryFileNames: '[name].cjs', |
53 | | - exports: 'named' |
54 | | - } |
55 | | - ] |
| 51 | + preserveModulesRoot: "src", |
| 52 | + entryFileNames: "[name].cjs", |
| 53 | + exports: "named", |
| 54 | + }, |
| 55 | + ], |
56 | 56 | }, |
57 | | - outDir: 'dist', |
| 57 | + outDir: "dist", |
58 | 58 | emptyOutDir: true, |
59 | | - sourcemap: true |
60 | | - } |
| 59 | + sourcemap: true, |
| 60 | + }, |
61 | 61 | }); |
0 commit comments