Ai
4 Star 45 Fork 13

ghost-him/ZeroLaunch-rs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
ghost-him 提交于 2025-11-21 17:57 +08:00 . refactor: restructure ui components
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { copyFileSync, mkdirSync, existsSync, readdirSync } from "fs";
import { join } from "path";
const host = process.env.TAURI_DEV_HOST;
// https://vitejs.dev/config/
// 自定义插件:复制i18n locales到src-tauri
const copyI18nPlugin = () => {
return {
name: 'copy-i18n-locales',
buildStart() {
const srcLocalesDir = join(process.cwd(), 'src-ui', 'i18n', 'locales');
const destDir = join(process.cwd(), 'src-tauri', 'locales');
// 创建目标目录
if (!existsSync(destDir)) {
mkdirSync(destDir, { recursive: true });
}
if (!existsSync(destDir)) {
mkdirSync(destDir, { recursive: true });
}
// 复制locales文件夹中的所有文件
try {
const files = readdirSync(srcLocalesDir);
files.forEach(file => {
const srcFile = join(srcLocalesDir, file);
const destFile = join(destDir, file);
copyFileSync(srcFile, destFile);
});
console.log(`✓ ${files.length} i18n locales files copied to src-tauri/locales/`);
} catch (error) {
console.error('Failed to copy i18n locales:', error);
}
}
};
};
export default defineConfig(async () => ({
plugins: [vue(), copyI18nPlugin()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 12345,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Rust
1
https://gitee.com/ghost-him/ZeroLaunch-rs.git
git@gitee.com:ghost-him/ZeroLaunch-rs.git
ghost-him
ZeroLaunch-rs
ZeroLaunch-rs
main

搜索帮助