fix: 修复 Docke build 不处理软链接的问题

This commit is contained in:
samlm0
2024-01-15 23:03:22 +00:00
parent 70b7e84f81
commit f48e2aa85a

View File

@@ -5,9 +5,11 @@ import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import fs from 'node:fs'
import path from 'node:path'
// https://vitejs.dev/config/
export default defineConfig((e) => {
export default defineConfig(({ command }) => {
return {
server: {
proxy: {
@@ -36,6 +38,25 @@ export default defineConfig((e) => {
}
]
}),
{
name: 'build-script',
buildStart(options) {
if (command === 'build') {
const dirPath = path.join(__dirname, 'public');
const fileBuildRequired = {
"speedtest_worker.js": "../speedtest/speedtest_worker.js"
};
for (var dest in fileBuildRequired) {
const source = fileBuildRequired[dest]
if (fs.existsSync(dirPath + "/" + dest)) {
fs.unlinkSync(dirPath + "/" + dest)
}
fs.copyFileSync(dirPath + "/" + source, dirPath + "/" + dest)
}
}
},
},
Components({
resolvers: [NaiveUiResolver()]
})