import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import legacy from '@vitejs/plugin-legacy' import * as fs from 'node:fs' import * as path from 'node:path' export default defineConfig(({ mode }) => { return { plugins: [vue(), legacy({ targets: ['> 0.1%', 'not dead','chrome <= 66'], additionalLegacyPolyfills: [ 'core-js/stable', 'regenerator-runtime/runtime', ], }), { name: 'setting-txt', generateBundle() { const filePath = path.resolve(__dirname, 'src/static/setting.txt'); // 请确保路径正确 if (fs.existsSync(filePath)) { let content = fs.readFileSync(filePath, 'utf-8'); let count = parseInt(content, 10) || 0 count ++ fs.writeFileSync(filePath, count.toString(), 'utf-8'); } else { fs.writeFileSync(filePath, '1', 'utf-8'); } } } ], server: { host: '0.0.0.0', // 允许通过局域网访问 port: 5173, // 修改为你需要的端口号 }, resolve: { alias: { '@': '/src' } }, optimizeDeps: { include: ['vue','eruda'] }, base:'./', build: { sourcemap: mode === 'development' }, } })