Fix React dev mode using a base (#8428)
This commit is contained in:
parent
1947ef7a99
commit
67e8348594
4 changed files with 7 additions and 7 deletions
5
.changeset/cold-knives-peel.md
Normal file
5
.changeset/cold-knives-peel.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix React dev mode using a base
|
|
@ -45,7 +45,6 @@
|
||||||
"dev": "astro-scripts dev \"src/**/*.ts\""
|
"dev": "astro-scripts dev \"src/**/*.ts\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/internal-helpers": "0.2.0",
|
|
||||||
"@vitejs/plugin-react": "^4.0.4",
|
"@vitejs/plugin-react": "^4.0.4",
|
||||||
"ultrahtml": "^1.3.0"
|
"ultrahtml": "^1.3.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { appendForwardSlash } from '@astrojs/internal-helpers/path';
|
|
||||||
import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-react';
|
import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-react';
|
||||||
import type { AstroIntegration } from 'astro';
|
import type { AstroIntegration } from 'astro';
|
||||||
import { version as ReactVersion } from 'react-dom';
|
import { version as ReactVersion } from 'react-dom';
|
||||||
|
@ -94,7 +93,7 @@ export default function ({
|
||||||
return {
|
return {
|
||||||
name: '@astrojs/react',
|
name: '@astrojs/react',
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:setup': ({ config, command, addRenderer, updateConfig, injectScript }) => {
|
'astro:config:setup': ({ command, addRenderer, updateConfig, injectScript }) => {
|
||||||
addRenderer(getRenderer());
|
addRenderer(getRenderer());
|
||||||
updateConfig({
|
updateConfig({
|
||||||
vite: getViteConfiguration({ include, exclude, experimentalReactChildren }),
|
vite: getViteConfiguration({ include, exclude, experimentalReactChildren }),
|
||||||
|
@ -102,7 +101,7 @@ export default function ({
|
||||||
if (command === 'dev') {
|
if (command === 'dev') {
|
||||||
const preamble = FAST_REFRESH_PREAMBLE.replace(
|
const preamble = FAST_REFRESH_PREAMBLE.replace(
|
||||||
`__BASE__`,
|
`__BASE__`,
|
||||||
appendForwardSlash(config.base)
|
'/'
|
||||||
);
|
);
|
||||||
injectScript('before-hydration', preamble);
|
injectScript('before-hydration', preamble);
|
||||||
}
|
}
|
||||||
|
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
|
@ -4515,9 +4515,6 @@ importers:
|
||||||
|
|
||||||
packages/integrations/react:
|
packages/integrations/react:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@astrojs/internal-helpers':
|
|
||||||
specifier: 0.2.0
|
|
||||||
version: link:../../internal-helpers
|
|
||||||
'@vitejs/plugin-react':
|
'@vitejs/plugin-react':
|
||||||
specifier: ^4.0.4
|
specifier: ^4.0.4
|
||||||
version: 4.0.4(vite@4.4.9)
|
version: 4.0.4(vite@4.4.9)
|
||||||
|
|
Loading…
Add table
Reference in a new issue