-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
62 lines (56 loc) · 1.67 KB
/
vite.config.ts
File metadata and controls
62 lines (56 loc) · 1.67 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
import {fileURLToPath, URL} from 'node:url';
import {type InputOptions} from 'rollup';
import {defineConfig, LibraryFormats} from 'vite';
import vue from '@vitejs/plugin-vue';
import vueDevTools from 'vite-plugin-vue-devtools';
import {isCI} from 'ci-info';
import dts from 'vite-plugin-dts';
import tailwindcss from '@tailwindcss/vite';
// https://vite.dev/config/
const isProd = process.env.NODE_ENV === 'production';
const isPreview = process.env.GENERATE_PREVIEW_HTML === 'true';
// When running the build command with GENERATE_PREVIEW_HTML=true, also generate an index.html, which is not nessecary for production library builds.
const rollupInput: InputOptions['input'] = isPreview
? {'index.html': 'index.html'}
: undefined;
// When formatting the index.html for preview builds, the script tag points to the umd build incorrectly. As a workaround, we use the es build for preview builds.
const formats: LibraryFormats[] = isPreview ? ['es'] : ['es', 'umd', 'iife'];
export default defineConfig({
base:
isProd && isCI && !process.env.NETLIFY && !process.env.CF_PAGES
? '/address-widget/'
: '/',
plugins: [
vue(),
vueDevTools(),
dts({
entryRoot: 'src',
rollupTypes: true,
}),
tailwindcss(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
build: {
sourcemap: !isCI && isProd,
emptyOutDir: true,
lib: {
entry: 'src/main.ts',
fileName: 'main',
formats,
name: 'MyParcelAddressWidget',
},
rollupOptions: {
external: ['vue'],
input: rollupInput,
output: {
globals: {
vue: 'Vue',
},
},
},
},
});