-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.ts
78 lines (74 loc) · 2.17 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
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import { LibraryOptions, defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
const pathResolve = (dir: string) => {
return resolve(__dirname, '.', dir)
}
const alias: Record<string, string> = {
'@': pathResolve('./lib/')
}
const viteConfig = defineConfig(() => {
return {
plugins: [
vue(),
vueSetupExtend(),
dts({
entryRoot: './lib',
outDir: ['./dist'],
//指定使用的tsconfig.json为我们整个项目根目录下,如果不配置,你也可以在components下新建tsconfig.json
tsconfigPath: './tsconfig.json'
})
],
root: process.cwd(),
resolve: { alias },
base: './',
server: {
host: '0.0.0.0',
port: 9991,
open: true,
hmr: true
},
build: {
target: 'modules',
outDir: 'dist',
chunkSizeWarningLimit: 500,
lib: {
entry: 'lib/index.ts',
name: 'el-plus-crud',
formats: ['umd', 'es']
} as LibraryOptions,
rollupOptions: {
external: ['vue', 'element-plus'],
output: {
// entryFileNames: `static/js/[hash].js`,
// chunkFileNames: `static/js/[hash].js`,
// assetFileNames: (asser) => {
// const suff = asser.name?.substring(asser.name?.lastIndexOf('.') + 1) || ''
// switch (suff.toLowerCase()) {
// case 'js':
// return 'static/js/[hash].js'
// case 'css':
// return `static/css/[hash].css`
// case 'png':
// case 'jpg':
// case 'gif':
// case 'svg':
// return 'static/images/[hash].[ext]'
// }
// return `static/assets/[hash].[ext]`
// },
compact: true
},
minify: 'esbuild'
}
},
css: { preprocessorOptions: { css: { charset: false } } },
define: {
__NEXT_VERSION__: JSON.stringify(process.env.npm_package_version),
__NEXT_NAME__: JSON.stringify(process.env.npm_package_name)
}
}
})
export default viteConfig