mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-06-04 13:30:32 +08:00
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
import { resolve, dirname } from 'node:path'
|
|
import { existsSync } from 'node:fs'
|
|
import { createRequire } from 'node:module'
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const require = createRequire(import.meta.url)
|
|
|
|
function resolveVueOfficePptxEntry(): string {
|
|
try {
|
|
const pkgDir = dirname(require.resolve('@vue-office/pptx/package.json'))
|
|
const candidates = [
|
|
resolve(pkgDir, 'lib/v3/index.js'),
|
|
resolve(pkgDir, 'lib/index.js'),
|
|
resolve(pkgDir, 'lib/v3/vue-office-pptx.mjs'),
|
|
]
|
|
const matched = candidates.find((candidate) => existsSync(candidate))
|
|
return matched ?? '@vue-office/pptx'
|
|
} catch {
|
|
return '@vue-office/pptx'
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
'@vue-office/pptx': resolveVueOfficePptxEntry(),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
host: true,
|
|
// 代理配置,用于开发环境
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://127.0.0.1:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
},
|
|
'/files': {
|
|
target: 'http://127.0.0.1:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
}
|
|
}
|
|
}
|
|
})
|