-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
132 lines (124 loc) · 3.29 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/// <reference types="histoire" />
/// <reference types="vitest" />
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import banner from 'vite-plugin-banner'
import dts from 'vite-plugin-dts'
import analyze from 'rollup-plugin-analyzer'
import { visualizer } from 'rollup-plugin-visualizer'
import { resolve } from 'pathe'
import UnoCSS from 'unocss/vite'
import { presetUno, presetIcons, presetWebFonts, transformerDirectives } from 'unocss'
import { lightGreen, magenta, gray, bold } from 'kolorist'
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import pkg from './package.json'
function noop() {}
// eslint-disable-next-line no-console
console.log(`${lightGreen('▲')} ${gray('■')} ${magenta('🍰')} ${bold('Tres/leches')} v${pkg.version}`)
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
dts({
insertTypesEntry: true,
}),
banner({
content: `/**\n * name: ${pkg.name}\n * version: v${
pkg.version
}\n * (c) ${new Date().getFullYear()}\n * description: ${pkg.description}\n * author: ${pkg.author}\n */`,
}),
UnoCSS({
/* options */
presets: [
presetUno({
prefix: 'tl-',
variablePrefix: 'tl-',
}),
presetIcons({
scale: 1.2,
warn: true,
extraProperties: {
display: 'inline-block',
'vertical-align': 'middle',
// ...
},
}),
presetWebFonts({
fonts: {
sans: 'Roboto Mono',
},
}),
],
transformers: [transformerDirectives()],
}),
/* cssInjectedByJsPlugin(), */
],
test: {
environment: process.env.BROWSER_TEST ? 'node' : 'jsdom',
globals: true,
threads: false,
alias: {
'/@': resolve(__dirname, './src'),
},
isolate: !process.env.BROWSER_TEST,
browser: {
enabled: !!process.env.BROWSER_TEST,
// @ts-expect-error ignore, we don't have the type here in vitest
enableUI: true,
name: 'chrome',
headless: !!process.env.HEADLESS,
provider: 'webdriverio',
},
reporters: process.env.BROWSER_TEST
? [
'json',
{
onInit: noop,
onPathsCollected: noop,
onCollected: noop,
onFinished: noop,
onTaskUpdate: noop,
onTestRemoved: noop,
onWatcherStart: noop,
onWatcherRerun: noop,
onServerRestart: noop,
onUserConsoleLog: noop,
},
'default',
]
: undefined,
},
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'tresleches',
fileName: 'tresleches',
},
watch: {
include: [resolve(__dirname, 'src')],
},
rollupOptions: {
plugins: [
analyze(),
visualizer({
gzipSize: true,
brotliSize: true,
open: false,
}),
],
external: ['vue', '@vueuse/core'],
output: {
exports: 'named',
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
'@vueuse/core': 'VueUseCore',
vue: 'Vue',
},
},
},
},
optimizeDeps: {
exclude: ['vue', '@vueuse/core'],
},
})