Skip to content

Commit

Permalink
fix: macros (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Jul 15, 2023
1 parent c300db1 commit 010e53d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion storybook/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const GLOB_PATH = () => '../../src/components/ui/*/index.demo.(tsx|mdx)'
export const GLOB_PATH = '../../src/components/ui/*/index.demo.(tsx|mdx)'
2 changes: 1 addition & 1 deletion storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@vitejs/plugin-react": "^4.0.3",
"buffer": "6.0.3",
"concurrently": "^8.2.0",
"unplugin-macros": "0.4.2",
"unplugin-macros": "0.5.1",
"vite-tsconfig-paths": "^4.2.0"
}
}
25 changes: 16 additions & 9 deletions storybook/pnpm-lock.yaml

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

6 changes: 1 addition & 5 deletions storybook/src/glob.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import { Markdown } from './components/Mardown'

import { GLOB_PATH } from '../config' assert { type: 'macro' }
// TODO find project root
const modulesPath2PromiseMapping = import.meta.glob(
GLOB_PATH(),

{},
)
const modulesPath2PromiseMapping = import.meta.glob(GLOB_PATH)

// const mdxPath2PromiseMapping = import.meta.glob('../../*/index.demo.mdx', {
// as: 'raw',
Expand Down
12 changes: 8 additions & 4 deletions storybook/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs'
import path, { resolve } from 'node:path'
import react from '@vitejs/plugin-react'
import { parse } from 'dotenv'
import Macros from 'unplugin-macros/vite'
import Macros from 'unplugin-macros'
import { defineConfig } from 'vite'
import ViteRestart from 'vite-plugin-restart'
import tsConfigPaths from 'vite-tsconfig-paths'
Expand All @@ -24,10 +24,8 @@ const options = {
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Macros(),
Macros.vite(),
react(),
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

tsConfigPaths(),
mdx(options),
ViteRestart({
Expand All @@ -48,4 +46,10 @@ export default defineConfig({
'~': resolve(__dirname, '../src'),
},
},

optimizeDeps: {
esbuildOptions: {
plugins: [Macros.esbuild()],
},
},
})

0 comments on commit 010e53d

Please sign in to comment.