46 lines
1 KiB
TypeScript
46 lines
1 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
import { Plugin } from 'vite';
|
|
import fs from 'fs-extra';
|
|
|
|
// 复制 data 目录
|
|
function copyDataPlugin(): Plugin {
|
|
return {
|
|
name: 'copy-data',
|
|
async closeBundle() {
|
|
const source = path.resolve(__dirname, 'data');
|
|
const destination = path.resolve(__dirname, 'dist/data');
|
|
try {
|
|
await fs.copy(source, destination);
|
|
console.log('Copied data directory from ' + source + ' to ' + destination);
|
|
} catch (error) {
|
|
console.error('Error copying data directory:', error);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
copyDataPlugin()
|
|
],
|
|
optimizeDeps: {
|
|
exclude: ['lucide-react'],
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './'),
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
main: path.resolve(__dirname, 'index.html'),
|
|
},
|
|
},
|
|
copyPublicDir: true, // 复制 public 目录
|
|
},
|
|
});
|