-
Has anyone successfully run theme-ui with vite and typescript? I can't get it to work.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I realized overnight that the same problem would probably occur with emotion+vite (without theme-ui), so I searched for that, and found https://dev.to/ajitsinghkamal/using-emotionjs-with-vite-2ndj . A fix for this problem is to add an export default defineConfig({
plugins: [reactRefresh()],
esbuild: {
jsxFactory: 'jsx',
jsxInject: 'import {jsx} from "theme-ui"',
}
}) With this approach, there's no need for the /** @jsxImportSource theme-ui */ Note that this is probably also dependent on |
Beta Was this translation helpful? Give feedback.
I realized overnight that the same problem would probably occur with emotion+vite (without theme-ui), so I searched for that, and found https://dev.to/ajitsinghkamal/using-emotionjs-with-vite-2ndj . A fix for this problem is to add an
esbuild
section tovite.config.ts
, that tells how to deal with jsx:With this approach, there's no need for the
jsxImportSource
pragma:/** @jsxImportSource theme-ui */
Note that this is probably also dependent on
"jsx": "preserve"
in mytsconfig.json
.