Skip to content

Commit

Permalink
Fix React dev mode using a base (#8428)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored Sep 6, 2023
1 parent 1947ef7 commit 67e8348
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-knives-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/react': patch
---

Fix React dev mode using a base
1 change: 0 additions & 1 deletion packages/integrations/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
"@astrojs/internal-helpers": "0.2.0",
"@vitejs/plugin-react": "^4.0.4",
"ultrahtml": "^1.3.0"
},
Expand Down
5 changes: 2 additions & 3 deletions packages/integrations/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { appendForwardSlash } from '@astrojs/internal-helpers/path';
import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-react';
import type { AstroIntegration } from 'astro';
import { version as ReactVersion } from 'react-dom';
Expand Down Expand Up @@ -94,15 +93,15 @@ export default function ({
return {
name: '@astrojs/react',
hooks: {
'astro:config:setup': ({ config, command, addRenderer, updateConfig, injectScript }) => {
'astro:config:setup': ({ command, addRenderer, updateConfig, injectScript }) => {
addRenderer(getRenderer());
updateConfig({
vite: getViteConfiguration({ include, exclude, experimentalReactChildren }),
});
if (command === 'dev') {
const preamble = FAST_REFRESH_PREAMBLE.replace(
`__BASE__`,
appendForwardSlash(config.base)
'/'
);
injectScript('before-hydration', preamble);
}
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 67e8348

Please sign in to comment.