-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
62 lines (61 loc) · 1.72 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
/// <reference types="vitest" />
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import path, { resolve } from 'path'
import dts from 'vite-plugin-dts';
import { libInjectCss } from 'vite-plugin-lib-inject-css';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
dts({
include: ['lib'],
tsconfigPath: 'tsconfig.lib.json',
rollupTypes: true,
}),
libInjectCss(),
],
server: {
port: 3000,
},
build: {
copyPublicDir: false,
lib: {
entry: {
index: resolve(__dirname, 'lib/index.ts'),
button: resolve(__dirname, 'lib/components/Button/index.tsx'),
input: resolve(__dirname, 'lib/components/Input/index.tsx'),
label: resolve(__dirname, 'lib/components/Label/index.tsx'),
form: resolve(__dirname, 'lib/components/Form/index.tsx'),
},
formats: ['es'],
name: 'ViteReactComponents',
fileName: (format) => `vrc.${format}.js`,
},
rollupOptions: {
external: ['react', 'react/jsx-runtime', 'react-dom'],
output: {
// Put chunk files at <output>/chunks
chunkFileNames: 'chunks/[name].[hash].js',
// Put chunk styles at <output>/assets
assetFileNames: 'assets/[name][extname]',
entryFileNames: '[name].js',
// Register externals/globals
globals: {
react: "React",
"react-dom": "ReactDOM",
"react/jsx-runtime": "JSXRuntime",
},
}
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, './lib/index'),
'@/*': path.resolve(__dirname, './lib/*'),
},
},
test: {
include: ['./vitest/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
},
});