Skip to content

Commit 524bef4

Browse files
Fix: Update Vite alternate config for TypeScript support (#8148)
- Add filter parameter to match .js, .jsx, .ts, and .tsx files - Include @babel/preset-typescript for TypeScript support - Add ReactCompilerConfig variable for consistency - Align with React Router configuration pattern
1 parent 2534424 commit 524bef4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/content/learn/react-compiler/installation.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,24 @@ Alternatively, if you prefer a separate Babel plugin for Vite:
8888
npm install -D vite-plugin-babel
8989
</TerminalBlock>
9090

91-
```js {2,11}
91+
```js {2,11-18}
9292
// vite.config.js
9393
import babel from 'vite-plugin-babel';
9494
import { defineConfig } from 'vite';
9595
import react from '@vitejs/plugin-react';
9696

97+
const ReactCompilerConfig = { /* ... */ };
98+
9799
export default defineConfig({
98100
plugins: [
99101
react(),
100102
babel({
103+
filter: /\.[jt]sx?$/,
101104
babelConfig: {
102-
plugins: ['babel-plugin-react-compiler'],
105+
presets: ["@babel/preset-typescript"], // if you use TypeScript
106+
plugins: [
107+
["babel-plugin-react-compiler", ReactCompilerConfig],
108+
],
103109
},
104110
}),
105111
],

0 commit comments

Comments
 (0)