-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
107 lines (100 loc) · 2.95 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
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
/** 增强vue setup 语法 */
import VueMacros from 'unplugin-vue-macros/vite'
/** 新增导入类型 */
import dts from 'vite-plugin-dts'
import { resolve } from 'path'
// import { createHtmlPlugin } from 'vite-plugin-html'
// import AutoImport from 'unplugin-auto-import/vite'
// import ViteComponents from 'unplugin-vue-components/vite'
// import { VantResolver } from 'unplugin-vue-components/resolvers'
// import pxtovw from 'cnjm-postcss-px-to-viewport'
// import AutoPrefixer from 'autoprefixer'
// import Icons from 'unplugin-icons/vite'
// import { FileSystemIconLoader } from 'unplugin-icons/loaders'
// import IconsResolver from 'unplugin-icons/resolver'
export default defineConfig((configEnv) => {
// const { VITE_APP_TITLE, VITE_BASE_URL } = loadEnv(configEnv.mode, process.cwd()) as ImportMetaEnv
return {
/**插件 */
plugins: [
vue(),
dts({
outputDir: resolve(__dirname, 'dist/es'),
tsConfigFilePath: './tsconfig.json',
/** 处理生成的类型文件 目录不对应 */
beforeWriteFile: (filepath, content) => {
return {
filePath: filepath.replace('packages', ''),
content,
}
},
exclude: ['play/**/*.ts', 'play/**/*.vue'],
// staticImport: true,
}),
dts({
outputDir: resolve(__dirname, 'dist/lib'),
tsConfigFilePath: './tsconfig.json',
beforeWriteFile: (filepath, content) => {
return {
filePath: filepath.replace('packages', ''),
content,
}
},
exclude: ['play/**/*.ts', 'play/**/*.vue'],
}),
VueMacros(),
],
/**配置别名 */
resolve: {
alias: {
'@rising-ui/': resolve(__dirname, 'packages/'),
},
},
/**配置生产环境 */
build: {
// minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
// outDir: 'mobile',
target: 'modules',
// outDir: resolve(__dirname, 'rising-ui/es'),
minify: false,
rollupOptions: {
external: ['vue'],
input: ['packages/rising-ui/index.ts'],
preserveEntrySignatures: 'strict',
output: [
{
format: 'es',
entryFileNames: '[name].mjs',
preserveModules: true,
dir: resolve(__dirname, 'dist/es'),
preserveModulesRoot: 'dist',
},
{
format: 'cjs',
entryFileNames: '[name].cjs',
preserveModules: true,
dir: resolve(__dirname, 'dist/lib'),
preserveModulesRoot: 'dist',
},
{
global: {
vue: 'Vue',
},
},
],
},
// lib: {
// entry: 'packages/rising-ui/index.ts',
// formats: [],
// },
},
}
})