-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvite.config.ts
81 lines (80 loc) · 2.26 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
import path from 'path'
import fs from 'fs'
import process from 'process'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ArcoResolver } from 'unplugin-vue-components/resolvers'
import { createStyleImportPlugin } from 'vite-plugin-style-import'
import postBuildPlugin from './build/postBuildPlugin'
export default defineConfig({
base: './',
resolve: {
alias: {
'@': '/src'
},
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.vue']
},
optimizeDeps: {
entries: ['monaco-editor', '@arco-design/web-vue'],
needsInterop: [
'monaco-editor/esm/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp',
'monaco-editor/esm/vs/editor/contrib/documentSymbols/browser/documentSymbols',
'monaco-editor/esm/vs/editor/contrib/format/browser/formatActions, monaco-editor/esm/vs/editor/contrib/inPlaceReplace/browser/inPlaceReplace',
'monaco-editor/esm/vs/editor/standalone/browser/inspectTokens/inspectTokens'
]
},
build: {
rollupOptions: {
output: {
manualChunks: (e) => {
if (e.includes('/node_modules/monaco-editor/')) return 'monaco'
return 'vendor'
}
},
external: ['electron', 'utools', 'process', 'vm', 'fs']
}
},
esbuild: {
drop: process.env.NODE_ENV === 'production' ? ['console'] : []
},
server: {
port: 8084
},
plugins: [
vue({
script: {
defineModel: true
}
}),
AutoImport({
imports: ['vue', 'vue-router', 'pinia'],
resolvers: [ArcoResolver()]
}),
Components({
resolvers: [
ArcoResolver({
sideEffect: true
})
]
}),
createStyleImportPlugin({
libs: [
{
libraryName: '@arco-design/web-vue',
esModule: true,
resolveStyle: (name) => {
const p = `@arco-design/web-vue/es/${name}/style/css.js`
const actualPath = path.resolve(__dirname, 'node_modules', p)
if (fs.existsSync(actualPath)) return p
return ''
}
}
]
}),
postBuildPlugin({
files: ['index.html', 'plugin.json', 'preload.js']
})
]
})