summaryrefslogtreecommitdiff
path: root/packages/renderers/renderer-preact/compat/index.js
blob: a5580f04d742f869c3f86cb25fe50da4294ed9c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
export default {
	name: '@astrojs/renderer-preact/compat',
	client: '../client.js',
	server: '../server.js',
	jsxImportSource: 'react',
	jsxTransformOptions: async () => {
		const {
			default: { default: jsx },
		} = await import('@babel/plugin-transform-react-jsx');
		return {
			plugins: [jsx({}, { runtime: 'automatic', importSource: 'preact/compat' })],
		};
	},
	viteConfig() {
		return {
			alias: {
				react: 'preact/compat',
				'react-dom': 'preact/compat',
			},
			resolve: {
				dedupe: ['react', 'react-dom'],
			},
			optimizeDeps: {
				include: [
					'@astrojs/renderer-preact/client.js',
					'preact/compat',
					'preact/compat/jsx-runtime',
					'preact-render-to-string',
				],
			},
			ssr: {
				external: ['preact-render-to-string'],
			},
		};
	},
};