-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.lib.config.ts
36 lines (32 loc) · 1.05 KB
/
vite.lib.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
import path from 'node:path'
import { mergeConfig } from 'vite'
import dts from 'vite-plugin-dts'
import baseConfig from './vite.base.config'
import type { UserConfig } from 'vite'
// https://vitejs.dev/config/
export default mergeConfig(baseConfig, {
plugins: [dts({
exclude: '**/demos',
})],
build: {
minify: false,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
formats: ['es'],
},
rollupOptions: {
// inspired from: https://github.com/vitejs/vite/discussions/1736#discussioncomment-2621441
// preserveModulesRoot: https://rollupjs.org/guide/en/#outputpreservemodulesroot
output: {
dir: 'dist',
preserveModules: true,
preserveModulesRoot: 'src',
entryFileNames: '[name].js',
},
// ref: https://github.com/vitejs/vite/issues/4454#issuecomment-1407461535
// eslint-disable-next-line regexp/no-unused-capturing-group
external: (source, _, isResolved) => !(isResolved || /(^[./])|(^@\/)/.test(source)),
},
target: 'esnext',
},
} as UserConfig)