Fix React dev mode using a base (#8428)

This commit is contained in:
Matthew Phillips 2023-09-06 21:13:36 +08:00 committed by GitHub
parent 1947ef7a99
commit 67e8348594
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/react': patch
---
Fix React dev mode using a base

View file

@ -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"
},

View file

@ -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';
@ -94,7 +93,7 @@ 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 }),
@ -102,7 +101,7 @@ export default function ({
if (command === 'dev') {
const preamble = FAST_REFRESH_PREAMBLE.replace(
`__BASE__`,
appendForwardSlash(config.base)
'/'
);
injectScript('before-hydration', preamble);
}

View file

@ -4515,9 +4515,6 @@ importers:
packages/integrations/react:
dependencies:
'@astrojs/internal-helpers':
specifier: 0.2.0
version: link:../../internal-helpers
'@vitejs/plugin-react':
specifier: ^4.0.4
version: 4.0.4(vite@4.4.9)