new-api/web/vite.config.js
2024-03-23 19:09:09 +08:00

39 lines
804 B
JavaScript

import { defineConfig, transformWithEsbuild } from 'vite';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
{
name: 'treat-js-files-as-jsx',
async transform(code, id) {
if (!id.match(/src\/.*\.js$/)) return null
// Use the exposed transform from vite, instead of directly
// transforming with esbuild
return transformWithEsbuild(code, id, {
loader: 'jsx',
jsx: 'automatic',
})
},
},
react(),
],
optimizeDeps: {
force: true,
esbuildOptions: {
loader: {
'.js': 'jsx',
},
},
},
server: {
proxy: {
'/api': {
target: "http://localhost:3000",
changeOrigin: true,
}
}
}
});