33 lines
792 B
TypeScript
33 lines
792 B
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path'
|
|
import fs from 'fs'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
{
|
|
name: 'serve-favicon',
|
|
configureServer(server) {
|
|
server.middlewares.use((req, res, next) => {
|
|
if (req.url === '/favicon.png') {
|
|
const faviconPath = path.resolve(__dirname, '../favicon.png');
|
|
if (fs.existsSync(faviconPath)) {
|
|
res.setHeader('Content-Type', 'image/png');
|
|
fs.createReadStream(faviconPath).pipe(res);
|
|
return;
|
|
}
|
|
}
|
|
next();
|
|
});
|
|
}
|
|
}
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
})
|