feat: 更新 jsEncrypt 导入路径,优化 Vite 配置以支持 cmvr-iot-common
This commit is contained in:
parent
73ee3fe080
commit
d81dab5604
@ -1,4 +1,4 @@
|
|||||||
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
|
import JSEncrypt from 'jsencrypt'
|
||||||
|
|
||||||
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,18 @@
|
|||||||
import { defineConfig, loadEnv, normalizePath } from 'vite'
|
import { defineConfig, loadEnv, normalizePath } from 'vite'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import { realpathSync } from 'node:fs'
|
||||||
import createVitePlugins from './vite/plugins'
|
import createVitePlugins from './vite/plugins'
|
||||||
|
|
||||||
|
const isCommonLinked = (() => {
|
||||||
|
try {
|
||||||
|
const linkedPath = realpathSync(path.resolve('node_modules/@cmvr/iot-common'))
|
||||||
|
const localPath = realpathSync(path.resolve('../cmvr-iot-common'))
|
||||||
|
return path.relative(linkedPath, localPath) === ''
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({ mode, command }) => {
|
export default defineConfig(({ mode, command }) => {
|
||||||
const env = loadEnv(mode, process.cwd())
|
const env = loadEnv(mode, process.cwd())
|
||||||
@ -12,6 +23,7 @@ export default defineConfig(({ mode, command }) => {
|
|||||||
plugins: createVitePlugins(env, command === 'build'),
|
plugins: createVitePlugins(env, command === 'build'),
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
exclude: [
|
exclude: [
|
||||||
|
...(isCommonLinked ? ['@cmvr/iot-common'] : []),
|
||||||
'monaco-editor',
|
'monaco-editor',
|
||||||
'monaco-editor/esm/vs/base/worker/workerMain.js',
|
'monaco-editor/esm/vs/base/worker/workerMain.js',
|
||||||
'monaco-editor/esm/vs/editor/editor.main.js',
|
'monaco-editor/esm/vs/editor/editor.main.js',
|
||||||
@ -57,6 +69,11 @@ export default defineConfig(({ mode, command }) => {
|
|||||||
port: Number(VITE_PORT || 80),
|
port: Number(VITE_PORT || 80),
|
||||||
host: true,
|
host: true,
|
||||||
open: true,
|
open: true,
|
||||||
|
...(isCommonLinked ? {
|
||||||
|
watch: {
|
||||||
|
ignored: ['!**/node_modules/@cmvr/iot-common/**']
|
||||||
|
}
|
||||||
|
} : {}),
|
||||||
proxy: {
|
proxy: {
|
||||||
// https://cn.vitejs.dev/config/#server-proxy
|
// https://cn.vitejs.dev/config/#server-proxy
|
||||||
'/dev-api': {
|
'/dev-api': {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export default function createAutoImport() {
|
|||||||
'@/utils/ruoyi': ['selectDictLabel']
|
'@/utils/ruoyi': ['selectDictLabel']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
exclude: [/[\\/]cmvr-iot-common[\\/]dist[\\/]/],
|
||||||
dts: false
|
dts: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user