-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
65 lines (59 loc) · 1.74 KB
/
Copy pathvite.config.ts
File metadata and controls
65 lines (59 loc) · 1.74 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
55
56
57
58
59
60
61
62
63
64
65
import { fileURLToPath, URL } from 'node:url'
import type { UserConfigExport } from 'vite'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import dts from 'vite-plugin-dts'
export default defineConfig(ctx => {
const alias: Record<string, string> = {
'@': fileURLToPath(new URL('./src', import.meta.url)),
events: 'events',
path: 'path-browserify',
stream: 'stream-browserify',
zlib: 'browserify-zlib'
}
if (ctx.mode !== 'lib') {
alias['@file-viewer/core'] = fileURLToPath(new URL('../../core/src/index.ts', import.meta.url))
}
const config: UserConfigExport = {
plugins: [vue(), vueJsx()],
base: './',
resolve: {
alias
}
}
if (ctx.mode === 'lib') {
// TypeScript 6 no longer gives declaration plugins the old implicit root.
// Keep the published 2.x type entry stable at dist/src/package/index.d.ts
// instead of silently flattening it to dist/index.d.ts.
config.plugins?.push(dts({
entryRoot: fileURLToPath(new URL('.', import.meta.url)),
rollupTypes: true
}))
config.build = {
target: 'es2015',
copyPublicDir: false,
emptyOutDir: true,
lib: {
entry: fileURLToPath(new URL('src/package/index.ts', import.meta.url)),
name: 'fileViewerVue3',
formats: ['es'],
fileName: format => format === 'es' ? 'index.mjs' : 'index.umd.js'
},
rollupOptions: {
external: ['vue', '@file-viewer/core'],
output: {
chunkFileNames: 'components/[name].js'
}
}
}
config.worker = {
rollupOptions: {
output: {
entryFileNames: 'worker/[name].js'
}
}
}
}
return config
})