-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Preact + Vite] Internal server error: $RefreshSig$ is not defined #1379
Comments
Try updating the Vite's config disabling
|
I had the same problem in Astro with Preact and this fixed it! I copied the @astrojs/preact integration from https://github.com/withastro/astro/blob/main/packages/integrations/preact/src/index.ts to a new file inside my project and added ...
const preactPlugin = preact({
include,
exclude,
+ prefreshEnabled: false,
babel: {
cwd: fileURLToPath(babelCwd),
},
});
... maybe this helps somebody with the same problem. |
Disabling prefresh is a workaround with some drawbacks. We had the same issue, but I didn't want to sacrifice the nice DX prefresh brings. Instead I added the missing part to the context to be available during the transformation import wyw from '@wyw-in-js/vite';
//...
wyw({
// all your options
overrideContext: context => (env.mode === 'development'
? { ...context, $RefreshSig$: () => () => () => {} }
: context),
}), |
It works perfectly. Many thanks! For whom want export default defineConfig({
plugins: [
// ... your plugins
linaria({
include: ["**/*.{ts,tsx}"],
babelOptions: {
presets: ["@babel/preset-typescript", "@babel/preset-react"],
},
// Lines need to be added → change true condition to your condition (i.e. environment)
overrideContext: (context) =>
true ? { ...context, $RefreshSig$: () => () => () => {} } : context,
}),
],
server: {},
}); |
Environment
My configs
package.json
vite.config.ts
Description
There is error overlay shows that
[plugin:linaria] $RefreshSig$ is not defined
in development mode (npm run dev
) → Either I comment all Linaria related code in my component (particularlystyled
) or comment used custom hook, the error disappears.I cannot found any solutions or reasons about this error.
File that error occur
MyComponent.tsx
Comment Linaria code will work
or comment custom hook will work
The text was updated successfully, but these errors were encountered: