feat: vite as build tool

This commit is contained in:
Rafael 2024-11-30 09:47:43 +00:00
parent f936386712
commit 00dc3d0fcd
120 changed files with 21298 additions and 15076 deletions

View file

@ -0,0 +1,52 @@
import { fileURLToPath } from 'url'
import { defineConfig, transformWithEsbuild } from 'vite'
import react from '@vitejs/plugin-react-swc'
import svgr from 'vite-plugin-svgr'
import fixReactVirtualized from 'esbuild-plugin-react-virtualized'
export default defineConfig({
base: '/',
server: {
port: 3001,
proxy: {
'/graphql': {
target: 'https://localhost:8070/graphql',
changeOrigin: true,
secure: false
}
}
},
optimizeDeps: {
esbuildOptions: {
loader: {
'.js': 'jsx',
},
plugins: [
fixReactVirtualized,
],
}
},
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(),
svgr(),
],
resolve: {
alias: {
'src': fileURLToPath(new URL('./src', import.meta.url))
},
},
})