-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathvite-lib.config.js
More file actions
54 lines (52 loc) · 1.96 KB
/
Copy pathvite-lib.config.js
File metadata and controls
54 lines (52 loc) · 1.96 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import { readFileSync } from 'fs'
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8'))
const externalDeps = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
]
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
loadPaths: [path.resolve(__dirname)],
silenceDeprecations: ['import'],
},
},
},
build: {
copyPublicDir: false,
outDir: 'lib',
lib: {
entry: {
index: path.resolve(__dirname, 'admiral/index.ts'),
'ui/index': path.resolve(__dirname, 'admiral/ui/index.ts'),
'auth/index': path.resolve(__dirname, 'admiral/auth/index.ts'),
'locale/index': path.resolve(__dirname, 'admiral/locale/index.ts'),
'theme/index': path.resolve(__dirname, 'admiral/theme/index.ts'),
'crud/index': path.resolve(__dirname, 'admiral/crud/index.tsx'),
'form/index': path.resolve(__dirname, 'admiral/form/index.tsx'),
'admin/index': path.resolve(__dirname, 'admiral/admin/index.tsx'),
'router/index': path.resolve(__dirname, 'admiral/router/index.tsx'),
},
formats: ['es'],
},
rollupOptions: {
external: (id) => {
// Externalize all dependencies and their sub-paths
return externalDeps.some((dep) => id === dep || id.startsWith(dep + '/'))
},
output: {
preserveModules: true,
preserveModulesRoot: 'admiral',
entryFileNames: '[name].mjs',
assetFileNames: 'admiral.[ext]',
},
},
},
})