-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.mts
43 lines (40 loc) · 1.19 KB
/
vite.config.mts
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
import { defineConfig, loadEnv, type UserConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig(async ({ isSsrBuild, mode }) => {
const { svelte } = await import('@sveltejs/vite-plugin-svelte')
const env = loadEnv(mode, process.cwd(), '')
const isGlobal = !!env.BUILD_GLOBAL
const config: UserConfig = {
plugins: [
svelte({
compilerOptions: {
cssHash: ({ hash, css }) => `phr-${hash(css)}`,
},
}),
],
build: {
target: 'es2015',
outDir: isSsrBuild ? 'dist/server' : 'dist',
emptyOutDir: !isGlobal,
lib: {
entry: 'src/index.ts',
name: 'pdfmakeHtmlRenderer',
formats: isGlobal ? ['iife'] : ['es', 'cjs'],
fileName(format) {
if (format === 'iife') return 'global.js'
if (format === 'umd') return 'umd.js'
if (format === 'cjs') return 'index.cjs'
return 'index.mjs'
},
},
rollupOptions: {
external: isGlobal ? [] : ['qrcode'],
output: {
// This suppresses the warning about having both a default and a named export
exports: 'named',
},
},
},
}
return config
})