summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/integrations/preact/src/index.ts47
1 files changed, 25 insertions, 22 deletions
diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts
index 7c7ad618d..67a972475 100644
--- a/packages/integrations/preact/src/index.ts
+++ b/packages/integrations/preact/src/index.ts
@@ -32,14 +32,17 @@ function getCompatRenderer(): AstroRenderer {
return {
plugins: [
jsx({}, { runtime: 'automatic', importSource: 'preact/compat' }),
- ['babel-plugin-module-resolver', {
- alias: {
- 'react': 'preact/compat',
- 'react-dom/test-utils': 'preact/test-utils',
- 'react-dom': 'preact/compat',
- 'react/jsx-runtime': 'preact/jsx-runtime'
- }
- }],
+ [
+ 'babel-plugin-module-resolver',
+ {
+ alias: {
+ react: 'preact/compat',
+ 'react-dom/test-utils': 'preact/test-utils',
+ 'react-dom': 'preact/compat',
+ 'react/jsx-runtime': 'preact/jsx-runtime',
+ },
+ },
+ ],
],
};
},
@@ -61,25 +64,25 @@ function getViteConfiguration(compat?: boolean): ViteUserConfig {
external: ['preact-render-to-string'],
},
};
-
+
if (compat) {
- viteConfig.optimizeDeps!.include!.push(
+ viteConfig.optimizeDeps!.include!.push(
'preact/compat',
'preact/test-utils',
- 'preact/compat/jsx-runtime',
+ 'preact/compat/jsx-runtime'
);
- viteConfig.resolve = {
- alias: [
+ viteConfig.resolve = {
+ alias: [
{ find: 'react', replacement: 'preact/compat' },
- { find: 'react-dom/test-utils', replacement: 'preact/test-utils' },
- { find: 'react-dom', replacement: 'preact/compat' },
- { find: 'react/jsx-runtime', replacement: 'preact/jsx-runtime' }
- ],
- dedupe: ['preact/compat'],
- };
- }
-
- return viteConfig
+ { find: 'react-dom/test-utils', replacement: 'preact/test-utils' },
+ { find: 'react-dom', replacement: 'preact/compat' },
+ { find: 'react/jsx-runtime', replacement: 'preact/jsx-runtime' },
+ ],
+ dedupe: ['preact/compat'],
+ };
+ }
+
+ return viteConfig;
}
export default function ({ compat }: { compat?: boolean } = {}): AstroIntegration {