- Install Storybook 10 with @storybook/react-vite framework - Fix React Router Vite plugin conflict by filtering it out in viteFinal (reactRouter() returns a plugin array, so the filter must flatten first) - Integrate Storybook stories as a vitest browser project via @storybook/addon-vitest - Point stories glob at app/ instead of scaffold stories/ dir - Remove unused @chromatic-com/storybook and @storybook/addon-onboarding addons - Clean up duplicate __dirname in vitest.config.ts Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: [{
|
|
find: /^~\/database\/(.*)$/,
|
|
replacement: path.resolve(__dirname, './database/$1')
|
|
}, {
|
|
find: /^~\/server\/(.*)$/,
|
|
replacement: path.resolve(__dirname, './server/$1')
|
|
}, {
|
|
find: /^~\/(.*)$/,
|
|
replacement: path.resolve(__dirname, './app/$1')
|
|
}, {
|
|
find: /^@\/(.*)$/,
|
|
replacement: path.resolve(__dirname, './app/$1')
|
|
}, {
|
|
find: 'app',
|
|
replacement: path.resolve(__dirname, './app')
|
|
}]
|
|
},
|
|
test: {
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
exclude: ['node_modules/', 'app/test/', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}', '**/types.ts']
|
|
},
|
|
projects: [{
|
|
extends: true,
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
setupFiles: ['./app/test/setup.ts']
|
|
}
|
|
}, {
|
|
extends: true,
|
|
plugins: [storybookTest({ configDir: path.join(__dirname, '.storybook') })],
|
|
test: {
|
|
name: 'storybook',
|
|
browser: {
|
|
enabled: true,
|
|
headless: true,
|
|
provider: 'playwright',
|
|
instances: [{ browser: 'chromium' }]
|
|
}
|
|
}
|
|
}]
|
|
}
|
|
});
|