Skip to content

Instantly share code, notes, and snippets.

@bluwy
Last active March 13, 2021 17:44
Show Gist options
  • Save bluwy/18b8d103cea5f823a95c4ce39d36a048 to your computer and use it in GitHub Desktop.
Save bluwy/18b8d103cea5f823a95c4ce39d36a048 to your computer and use it in GitHub Desktop.
VIte preset plugin
export default defineConfig({
plugins: [preactPreset()],
})
function preactPreset({ devtoolsInProd }) {
return [
{
name: 'preact-preset',
enforce: 'pre',
config: () => ({
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
jsxInject: `import { h, Fragment } from 'preact'`,
},
resolve: {
alias: {
'react-dom/test-utils': 'preact/test-utils',
'react-dom': 'preact/compat',
react: 'preact/compat',
},
},
}),
},
preactDevtoolsPlugin({ injectInProd: devtoolsInProd }),
prefresh(),
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment