chore: 初始化项目基础结构和资源文件
- 添加项目图标文件(app-icon.png、各平台图标) - 配置开发环境文件(.env、.nvmrc、.npmrc) - 添加静态资源文件(背景图片、字体、音频) - 初始化Tauri后端结构(build.rs、main.rs、模块文件) - 配置前端项目结构(TypeScript、Vue组件、样式) - 添加Node.js API服务基础结构 - 配置构建和开发工具(vite、prettier、gitignore)
This commit is contained in:
107
vite.simplified.config.ts
Normal file
107
vite.simplified.config.ts
Normal file
@ -0,0 +1,107 @@
|
||||
import { type ConfigEnv, type UserConfig, defineConfig } from 'vite';
|
||||
import Vue from '@vitejs/plugin-vue';
|
||||
import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { useViteCompression } from './vite/compression';
|
||||
import Icons from 'unplugin-icons/vite';
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
|
||||
/**
|
||||
* 简化入口专用配置
|
||||
* 仅包含 Vue 插件,用于构建 other_pages 中的页面
|
||||
*/
|
||||
export default defineConfig(({ command }: ConfigEnv): Promise<UserConfig> => {
|
||||
const isBuild = Boolean(command === 'build');
|
||||
|
||||
const config: UserConfig = {
|
||||
base: './',
|
||||
|
||||
// 只使用 Vue 插件
|
||||
plugins: [
|
||||
Vue({}),
|
||||
AutoImport({
|
||||
imports: ['vue'],
|
||||
vueTemplate: true, // Vue模板内自动导入
|
||||
}),
|
||||
// 注册 svgIcon
|
||||
Icons({
|
||||
autoInstall: true,
|
||||
compiler: 'vue3',
|
||||
customCollections: { my: FileSystemIconLoader(resolve(__dirname, 'src/assets/svg-icons/unplugin-icons')) },
|
||||
}),
|
||||
// 压缩
|
||||
useViteCompression(isBuild),
|
||||
],
|
||||
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
},
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
// 简化版不需要注入全局样式
|
||||
additionalData: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// 开发服务器配置
|
||||
server: {
|
||||
open: false,
|
||||
port: 4265, // 使用不同的端口避免冲突
|
||||
strictPort: false,
|
||||
cors: true,
|
||||
},
|
||||
|
||||
define: {
|
||||
__APP_VERSION_TIMESTAMP__: JSON.stringify(new Date().getTime()),
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
},
|
||||
|
||||
clearScreen: false,
|
||||
envPrefix: ['VITE_', 'TAURI_ENV_'],
|
||||
|
||||
build: {
|
||||
outDir: 'dist', // 输出到同一个目录
|
||||
emptyOutDir: false, // 不清空目录,保留主应用的构建产物
|
||||
cssCodeSplit: true,
|
||||
sourcemap: false,
|
||||
target: 'es2020',
|
||||
chunkSizeWarningLimit: 1150,
|
||||
assetsInlineLimit: 4096,
|
||||
minify: 'oxc',
|
||||
rollupOptions: {
|
||||
// 只构建简化入口
|
||||
input: {
|
||||
'floating-list-window': resolve(__dirname, 'floating-list-window.html'),
|
||||
'popup-window': resolve(__dirname, 'popup-window.html'),
|
||||
},
|
||||
output: {
|
||||
// 自定义输出文件名,避免与主应用冲突
|
||||
chunkFileNames: 'js/[name]-[hash].js',
|
||||
entryFileNames: 'js/[name]-[hash].js',
|
||||
assetFileNames: (assetInfo) => {
|
||||
const ext: string = assetInfo.name?.split('.').pop() || '';
|
||||
let extType: string = ext;
|
||||
if (['mp4', 'webm', 'ogg', 'mp3', 'wav', 'flac', 'aac'].includes(ext)) {
|
||||
extType = 'media';
|
||||
} else if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'ico'].includes(ext)) {
|
||||
extType = 'images';
|
||||
} else if (['woff', 'woff2', 'ttf', 'eot', 'otf'].includes(ext)) {
|
||||
extType = 'fonts';
|
||||
} else if (ext === 'css') {
|
||||
extType = 'css';
|
||||
} else {
|
||||
extType = 'assets';
|
||||
}
|
||||
return `${extType}/[name]-[hash].[ext]`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return Promise.resolve(config);
|
||||
});
|
||||
Reference in New Issue
Block a user