diff --git a/web/app/components/base/icons/icon-gallery.stories.tsx b/web/app/components/base/icons/icon-gallery.stories.tsx
index 15206f2735..8d49f70ce2 100644
--- a/web/app/components/base/icons/icon-gallery.stories.tsx
+++ b/web/app/components/base/icons/icon-gallery.stories.tsx
@@ -1,9 +1,9 @@
+///
import type { Meta, StoryObj } from '@storybook/nextjs-vite'
import * as React from 'react'
-declare const require: any
-
type IconComponent = React.ComponentType>
+type IconModule = { default: IconComponent }
type IconEntry = {
name: string
@@ -12,18 +12,16 @@ type IconEntry = {
Component: IconComponent
}
-const iconContext = require.context('./src', true, /\.tsx$/)
+const iconModules: Record = import.meta.glob('./src/**/*.tsx', { eager: true })
-const iconEntries: IconEntry[] = iconContext
- .keys()
- .filter((key: string) => !key.endsWith('.stories.tsx') && !key.endsWith('.spec.tsx'))
- .map((key: string) => {
- const mod = iconContext(key)
- const Component = mod.default as IconComponent | undefined
+const iconEntries: IconEntry[] = Object.entries(iconModules)
+ .filter(([key]) => !key.endsWith('.stories.tsx') && !key.endsWith('.spec.tsx'))
+ .map(([key, mod]) => {
+ const Component = mod.default
if (!Component)
return null
- const relativePath = key.replace(/^\.\//, '')
+ const relativePath = key.replace(/^\.\/src\//, '')
const path = `app/components/base/icons/src/${relativePath}`
const parts = relativePath.split('/')
const fileName = parts.pop() || ''
diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json
index 9f4d2da5d4..2c06b37115 100644
--- a/web/eslint-suppressions.json
+++ b/web/eslint-suppressions.json
@@ -1085,11 +1085,6 @@
"count": 2
}
},
- "app/components/base/icons/icon-gallery.stories.tsx": {
- "ts/no-explicit-any": {
- "count": 1
- }
- },
"app/components/base/icons/utils.ts": {
"ts/no-explicit-any": {
"count": 3
diff --git a/web/package.json b/web/package.json
index 85fce3a08a..5d8003d6d6 100644
--- a/web/package.json
+++ b/web/package.json
@@ -48,7 +48,7 @@
"analyze-component": "node ./scripts/analyze-component.js",
"refactor-component": "node ./scripts/refactor-component.js",
"storybook": "storybook dev -p 6006",
- "build-storybook": "storybook build",
+ "storybook:build": "storybook build",
"preinstall": "npx only-allow pnpm",
"analyze": "ANALYZE=true pnpm build",
"knip": "knip"
diff --git a/web/vite.config.ts b/web/vite.config.ts
new file mode 100644
index 0000000000..23fe36bce4
--- /dev/null
+++ b/web/vite.config.ts
@@ -0,0 +1,16 @@
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import react from '@vitejs/plugin-react'
+import { defineConfig } from 'vite'
+import tsconfigPaths from 'vite-tsconfig-paths'
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
+
+export default defineConfig({
+ plugins: [tsconfigPaths(), react()],
+ resolve: {
+ alias: {
+ '~@': __dirname,
+ },
+ },
+})
diff --git a/web/vitest.config.ts b/web/vitest.config.ts
index f6e8424e44..c58a92f217 100644
--- a/web/vitest.config.ts
+++ b/web/vitest.config.ts
@@ -1,9 +1,7 @@
-import react from '@vitejs/plugin-react'
-import tsconfigPaths from 'vite-tsconfig-paths'
-import { defineConfig } from 'vitest/config'
+import { defineConfig, mergeConfig } from 'vitest/config'
+import viteConfig from './vite.config'
-export default defineConfig({
- plugins: [tsconfigPaths(), react()],
+export default mergeConfig(viteConfig, defineConfig({
test: {
environment: 'jsdom',
globals: true,
@@ -13,4 +11,4 @@ export default defineConfig({
reporter: ['text', 'json', 'json-summary'],
},
},
-})
+}))