- 添加项目图标文件(app-icon.png、各平台图标) - 配置开发环境文件(.env、.nvmrc、.npmrc) - 添加静态资源文件(背景图片、字体、音频) - 初始化Tauri后端结构(build.rs、main.rs、模块文件) - 配置前端项目结构(TypeScript、Vue组件、样式) - 添加Node.js API服务基础结构 - 配置构建和开发工具(vite、prettier、gitignore)
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import type { BuildOptions } from 'vite';
|
|
/**
|
|
* 自定义底层的 rolldown 打包配置
|
|
*/
|
|
export function rolldownOptions(): BuildOptions['rolldownOptions'] {
|
|
return {
|
|
output: {
|
|
// 拆分代码
|
|
manualChunks: (id: string) => {
|
|
const lastPath = id;
|
|
if (lastPath.includes('node_modules')) {
|
|
if (lastPath.includes('pinia')) {
|
|
return 'store';
|
|
}
|
|
if (lastPath.includes('element-plus')) {
|
|
return 'element-plus';
|
|
}
|
|
if (lastPath.includes('echarts')) {
|
|
return 'echarts';
|
|
}
|
|
if (lastPath.includes('vue')) {
|
|
return 'vue';
|
|
}
|
|
}
|
|
return undefined;
|
|
},
|
|
chunkFileNames: 'js/[name]-[hash].js',
|
|
entryFileNames: 'js/[name]-[hash].js',
|
|
// assetFileNames: '[ext]/[name]-[hash].[ext]',
|
|
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]`;
|
|
},
|
|
},
|
|
};
|
|
}
|