astro/packages/renderers/renderer-react/index.js
Drew Powers 330620e1b3 Update renderer API for Vite (#1623)
* Update renderer API for Vite

* Fix lit-element tests

* Clean up comments

* Throw friendly error if renderer provides viteConfig in a bad format
2021-10-22 16:25:38 -06:00

27 lines
702 B
JavaScript

export default {
name: '@astrojs/renderer-react',
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: 'react' })],
};
},
viteConfig() {
return {
optimizeDeps: {
include: ['@astrojs/renderer-react/client.js', 'react', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom'],
},
resolve: {
dedupe: ['react', 'react-dom'],
},
ssr: {
external: ['react-dom/server.js'],
},
};
},
};