-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathvite.config.ts
44 lines (42 loc) · 1.04 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 { defineConfig, type PluginOption } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import path from 'node:path'
import { transformIndexHtmlPlugin } from './transformIndexHtmlPlugin'
function vitePluginUncommentWxs(files: string[]): PluginOption {
return {
name: 'vitePluginUncommentWxs',
enforce: 'pre',
transform(code, id) {
if (files.some((file) => id.includes(file))) {
return code.replace(
/<!-- (<script.*?lang="wxs"><\/script>) -->/gm,
'$1',
)
}
},
}
}
// https://vitejs.dev/config/
export default defineConfig({
optimizeDeps: {
exclude: ['sard-uniapp'],
force: true,
},
plugins: [
vitePluginUncommentWxs(['pull-down-refresh.vue']),
uni(),
transformIndexHtmlPlugin(),
],
resolve: {
alias: [
{
find: /^sard-uniapp/,
replacement: path.resolve(process.cwd(), './src/lib'),
},
{
find: /^sard-uniapp$/,
replacement: path.resolve(process.cwd(), './src/lib/index.ts'),
},
],
},
})