47 lines
852 B
JavaScript
47 lines
852 B
JavaScript
import { defineConfig, transformWithOxc } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
function jsxInJs() {
|
|
return {
|
|
name: 'vite-plugin-jsx-in-js',
|
|
enforce: 'pre',
|
|
async transform(code, id) {
|
|
if (id.endsWith('.js') && !id.includes('node_modules') && (code.includes('<') || code.includes('/>'))) {
|
|
return transformWithOxc(code, id, {
|
|
lang: 'jsx',
|
|
jsx: { runtime: 'automatic', importSource: 'react' }
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
jsxInJs(),
|
|
react(),
|
|
],
|
|
optimizeDeps: {
|
|
rolldownOptions: {
|
|
moduleTypes: {
|
|
'.js': 'jsx',
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://127.0.0.1:8000',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
|
|
|
|
|
|
|