Some checks failed
DSS Project Analysis / dss-context-update (push) Has been cancelled
- Button.css uses only CSS custom properties, no fallbacks - Token validator now blocks hardcoded values (strict_mode: true) - Hook scripts converted from ESM (.js) to CommonJS (.cjs) - Storybook unified config with HMR disabled for nginx proxy - Added dss-ui package with Figma-synced components and stories 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
95 lines
2.7 KiB
TypeScript
95 lines
2.7 KiB
TypeScript
import type { StorybookConfig } from '@storybook/preact-vite';
|
|
import { join, dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { readFileSync, existsSync } from 'fs';
|
|
|
|
// ESM-compatible __dirname
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
/**
|
|
* DSS Unified Storybook Configuration
|
|
*
|
|
* Loads stories from:
|
|
* 1. DSS Core (packages/dss-ui/stories/) - atoms, molecules, organisms
|
|
* 2. Active project stories - templates, pages, project-specific components
|
|
*
|
|
* Project selection is controlled via:
|
|
* 1. STORYBOOK_PROJECT env var (highest priority)
|
|
* 2. .dss/state.json activeProject field (managed by Claude/admin-ui)
|
|
* 3. Default: 'admin-ui'
|
|
*/
|
|
|
|
// Read active project from DSS state
|
|
function getActiveProject(): string {
|
|
// Env var takes priority
|
|
if (process.env.STORYBOOK_PROJECT) {
|
|
return process.env.STORYBOOK_PROJECT;
|
|
}
|
|
|
|
// Try reading from DSS state
|
|
const statePath = join(__dirname, '../.dss/state.json');
|
|
if (existsSync(statePath)) {
|
|
try {
|
|
const state = JSON.parse(readFileSync(statePath, 'utf-8'));
|
|
if (state.activeProject) {
|
|
return state.activeProject;
|
|
}
|
|
} catch (e) {
|
|
console.warn('Failed to read DSS state, using default project');
|
|
}
|
|
}
|
|
|
|
return 'admin-ui';
|
|
}
|
|
|
|
const activeProject = getActiveProject();
|
|
console.log(`[DSS] Active project: ${activeProject}`);
|
|
|
|
const config: StorybookConfig = {
|
|
stories: [
|
|
// DSS Core stories (always loaded)
|
|
'../packages/dss-ui/stories/**/*.stories.@(js|jsx|ts|tsx)',
|
|
'../packages/dss-ui/stories/**/*.mdx',
|
|
// Project-specific stories
|
|
`../${activeProject}/src/**/*.stories.@(js|jsx|ts|tsx)`,
|
|
`../${activeProject}/src/**/*.mdx`,
|
|
],
|
|
addons: [
|
|
'@storybook/addon-docs',
|
|
'@storybook/addon-a11y',
|
|
],
|
|
framework: {
|
|
name: '@storybook/preact-vite',
|
|
options: {},
|
|
},
|
|
docs: {
|
|
autodocs: 'tag',
|
|
},
|
|
staticDirs: [
|
|
'../packages/dss-ui/src/primitives',
|
|
],
|
|
viteFinal: async (config) => {
|
|
config.server = config.server || {};
|
|
config.server.allowedHosts = [
|
|
'localhost',
|
|
'storybook.dss.overbits.luz.uy'
|
|
];
|
|
// HMR configuration
|
|
// For local development: HMR works normally on localhost:6006
|
|
// For external access (storybook.dss.overbits.luz.uy): HMR is disabled
|
|
// because Vite uses a separate port (24678) that isn't proxied through nginx
|
|
// Disable HMR for external access - Vite's HMR websocket isn't proxied through nginx
|
|
config.server.hmr = false;
|
|
// Resolve packages for proper imports
|
|
config.resolve = config.resolve || {};
|
|
config.resolve.alias = {
|
|
...config.resolve.alias,
|
|
'@dss/ui': join(__dirname, '../packages/dss-ui/src'),
|
|
};
|
|
return config;
|
|
},
|
|
};
|
|
|
|
export default config;
|