-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
executable file
·72 lines (65 loc) · 1.74 KB
/
vite.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
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
66
67
68
69
70
71
72
/// <reference types="vitest" />
import tailwindcss from '@tailwindcss/vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import del from 'rollup-plugin-delete'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
const alias = {
'@': resolve(__dirname, './src'),
'@playground': resolve(__dirname, './playground'),
'@root': resolve(__dirname, './'),
}
const playgroundConfig = {
plugins: [vue(), tailwindcss()],
resolve: { alias },
build: { outDir: 'dist-playground' },
test: {
globals: true,
environment: 'jsdom',
reporters: ['default'],
coverage: {
reporter: ['text', 'json-summary'],
include: ['src/**'],
},
},
}
const libConfig = {
plugins: [
del({ targets: 'dist/favicon.ico', hook: 'writeBundle' }),
vue(),
// https://github.com/qmhc/vite-plugin-dts#options
dts({
exclude: ['playground/**'],
beforeWriteFile: function (filePath, content) {
// Write definition files in /dist/types/ instead of /dist/src/
const finalFilePath = filePath.replace('/dist/src/', '/dist/types/')
return { filePath: finalFilePath, content }
},
}),
],
resolve: { alias },
build: {
lib: {
entry: resolve(__dirname, 'src/SearchInput.vue'),
name: 'VueSearchInput',
fileName: (format) => `vue-search-input.${format}.js`,
},
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue',
},
},
},
},
}
const config = process.env.BUILD_MODE && process.env.BUILD_MODE === 'playground' ? playgroundConfig : libConfig
export default defineConfig(({ command }) => {
if (command === 'serve') {
return playgroundConfig
} else {
return config
}
})