-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvite.config.ts
60 lines (59 loc) · 1.62 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
import { resolve } from 'path'
import { defineConfig, loadEnv, PluginOption } from 'vite'
import Dts from 'vite-plugin-dts'
import { terser as Terser } from 'rollup-plugin-terser'
import Swc from 'unplugin-swc'
import { viteMockServe as ViteMockServe } from 'vite-plugin-mock'
import { createHtmlPlugin as CreateHtmlPlugin } from 'vite-plugin-html'
import { GenerateTags } from './plugins/injectHTML'
export default defineConfig(({ command, mode }) => {
const { VITE_APP_PROJECT_ICON, VITE_APP_PROJECT_TITLE } = loadEnv(
mode,
process.cwd()
)
return {
plugins: [
Swc.vite(),
Dts({
outputDir: 'dist/types',
entryRoot: 'packages'
}),
Terser(),
ViteMockServe({
mockPath: 'mock',
enable: command === 'serve',
watchFiles: false,
logger: true
}),
...CreateHtmlPlugin({
minify: true,
entry: '/examples/main.ts',
template: 'index.html',
inject: {
tags: GenerateTags({
icon: VITE_APP_PROJECT_ICON,
title: VITE_APP_PROJECT_TITLE
}),
data: {
doctype: '<!DOCTYPE html>'
}
}
})
] as PluginOption[],
resolve: {
alias: {
'@': resolve(__dirname, 'packages'),
'~@': resolve(__dirname, 'examples')
},
extensions: ['.ts', '.js', '.json', '.d.ts']
},
build: {
lib: {
entry: resolve(__dirname, './packages/index.ts'),
name: 'http-typedi',
fileName: 'http-typedi'
},
outDir: 'dist'
}
}
})