summaryrefslogtreecommitdiff
path: root/packages/integrations/react/src
diff options
context:
space:
mode:
authorGravatar fightingcat <knightcat.sq@gmail.com> 2024-04-05 01:57:20 +0800
committerGravatar GitHub <noreply@github.com> 2024-04-04 13:57:20 -0400
commit14f1d49a10541fecc4c10def8a094322442ccf23 (patch)
tree591e2a92f398f8f91e365255ed759c068a237b64 /packages/integrations/react/src
parente2a780a46d8c2fea81d516cb48ba45650d891282 (diff)
downloadastro-14f1d49a10541fecc4c10def8a094322442ccf23.tar.gz
astro-14f1d49a10541fecc4c10def8a094322442ccf23.tar.zst
astro-14f1d49a10541fecc4c10def8a094322442ccf23.zip
Expose Babel config for @astro/react. (#10675)
Diffstat (limited to 'packages/integrations/react/src')
-rw-r--r--packages/integrations/react/src/index.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts
index 30781396f..b4cfcc039 100644
--- a/packages/integrations/react/src/index.ts
+++ b/packages/integrations/react/src/index.ts
@@ -3,7 +3,7 @@ import type { AstroIntegration } from 'astro';
import { version as ReactVersion } from 'react-dom';
import type * as vite from 'vite';
-export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude'> & {
+export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude' | 'babel'> & {
experimentalReactChildren?: boolean;
};
@@ -46,6 +46,7 @@ function optionsPlugin(experimentalReactChildren: boolean): vite.Plugin {
function getViteConfiguration({
include,
exclude,
+ babel,
experimentalReactChildren,
}: ReactIntegrationOptions = {}) {
return {
@@ -65,7 +66,7 @@ function getViteConfiguration({
: '@astrojs/react/server-v17.js',
],
},
- plugins: [react({ include, exclude }), optionsPlugin(!!experimentalReactChildren)],
+ plugins: [react({ include, exclude, babel }), optionsPlugin(!!experimentalReactChildren)],
resolve: {
dedupe: ['react', 'react-dom', 'react-dom/server'],
},
@@ -89,6 +90,7 @@ function getViteConfiguration({
export default function ({
include,
exclude,
+ babel,
experimentalReactChildren,
}: ReactIntegrationOptions = {}): AstroIntegration {
return {
@@ -97,7 +99,7 @@ export default function ({
'astro:config:setup': ({ command, addRenderer, updateConfig, injectScript }) => {
addRenderer(getRenderer());
updateConfig({
- vite: getViteConfiguration({ include, exclude, experimentalReactChildren }),
+ vite: getViteConfiguration({ include, exclude, babel, experimentalReactChildren }),
});
if (command === 'dev') {
const preamble = FAST_REFRESH_PREAMBLE.replace(`__BASE__`, '/');