-
Notifications
You must be signed in to change notification settings - Fork 12
/
vite.config.ts
44 lines (38 loc) · 1.15 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
import { readFileSync } from 'node:fs'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import bannerPlugin from 'vite-plugin-banner'
import { default as cssInjectedByJsPlugin } from 'vite-plugin-css-injected-by-js'
type Pkg = { name: string, version: string, homepage: string }
const { name, version, homepage } = JSON.parse(readFileSync('./package.json', 'utf8')) as Pkg
const banner = `
/*!
* ${name} - v${version}
* ${homepage}
* Built: ${new Date().toUTCString()}
*/
`
const target = 'es2022'
export default defineConfig(({ command }) => {
if (command === 'serve') return { target }
return {
build: {
target,
lib: {
entry: './src/main.ts',
name: 'TimePicker',
fileName: 'timepicker',
formats: ['es', 'iife'],
},
rollupOptions: { output: { exports: 'named' } },
},
plugins: [
bannerPlugin(banner),
cssInjectedByJsPlugin(),
dts({ rollupTypes: true }),
],
define: {
__APP_VERSION__: JSON.stringify(version),
},
}
})