Skip to content

Commit

Permalink
refactor(vite-plugin): explicit react config option
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Jun 2, 2022
1 parent 54af8c5 commit ef4ed38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/vite-plugin-million/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parse, print, visit } from 'recast';
import MagicString from 'magic-string';
import { compile } from './compile';

const JSX_FILTER = /\.(jsx|tsx)$/;
Expand All @@ -11,14 +12,15 @@ export const million = (options?: { importSource: string; react: boolean }): any
enforce: 'pre',
config() {
const resolve =
options?.react === undefined || options?.react === true
options?.react === true
? {
alias: {
react: 'million/react',
'react-dom': 'million/react',
},
}
: {};

return {
esbuild: {
jsxFactory,
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
src: resolve(__dirname, './src'),
},
},
plugins: [million({ importSource: 'src/jsx-runtime' })],
plugins: [million({ importSource: 'src/jsx-runtime', react: true })],
test: {
watch: false,
environment: 'jsdom',
Expand Down

0 comments on commit ef4ed38

Please sign in to comment.