-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.react.ts
More file actions
51 lines (42 loc) · 1.22 KB
/
vite.config.react.ts
File metadata and controls
51 lines (42 loc) · 1.22 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
import { resolve } from 'node:path'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { externalizeCorePlugin } from './vite-plugins/externalize-core.js'
export default defineConfig({
plugins: [
externalizeCorePlugin(),
react(),
dts({
tsconfigPath: './tsconfig.react.json',
outDir: 'dist/react',
entryRoot: 'src/react',
}),
],
build: {
lib: {
entry: resolve(__dirname, 'src/react/index.ts'),
formats: ['es'],
fileName: () => 'index.js',
},
outDir: 'dist/react',
emptyOutDir: true,
// Extract CSS into a separate file
cssCodeSplit: false,
rollupOptions: {
external: (id) => {
// Externalize React
if (/^react(-dom)?(\/.*)?$/.test(id)) return true
if (id === 'react/jsx-runtime') return true
// Externalize @adonisjs/transmit-client
if (id.includes('@adonisjs/transmit-client')) return true
// Externalize bare core specifier (rewritten by plugin above)
if (id.startsWith('adonisjs-server-stats/core')) return true
return false
},
output: {
assetFileNames: 'style.[ext]',
},
},
},
})