refactor: repartition server-side and client-side code
This commit is contained in:
@@ -43,6 +43,7 @@ export default defineConfig((config) => {
|
||||
UnoCSS(),
|
||||
tsconfigPaths(),
|
||||
chrome129IssuePlugin(),
|
||||
excludeUploadsPlugin(),
|
||||
],
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
@@ -77,3 +78,25 @@ function chrome129IssuePlugin() {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function excludeUploadsPlugin() {
|
||||
return {
|
||||
name: 'exclude-uploads',
|
||||
apply: 'build' as const,
|
||||
enforce: 'post' as const,
|
||||
async closeBundle() {
|
||||
const fs = await import('fs');
|
||||
const path = await import('path');
|
||||
const uploadsPath = path.resolve(process.cwd(), 'build/client/uploads');
|
||||
|
||||
if (fs.existsSync(uploadsPath)) {
|
||||
try {
|
||||
fs.rmSync(uploadsPath, { recursive: true, force: true });
|
||||
console.log('✓ 已从构建产物中排除 uploads 目录');
|
||||
} catch (error) {
|
||||
console.warn('⚠ 删除 uploads 目录时出错:', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user