const path = require('path'); const fs = require('fs'); function getActiveProject() { if (process.env.STORYBOOK_PROJECT) { return process.env.STORYBOOK_PROJECT; } const statePath = path.join(__dirname, '../.dss/state.json'); if (fs.existsSync(statePath)) { try { const state = JSON.parse(fs.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}`); /** @type { import('@storybook/preact-vite').StorybookConfig } */ module.exports = { stories: [ '../packages/dss-ui/stories/**/*.stories.@(js|jsx|ts|tsx)', '../packages/dss-ui/stories/**/*.mdx', `../${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', }, viteFinal: async (config) => { config.server = config.server || {}; config.server.allowedHosts = [ 'localhost', 'storybook.dss.overbits.luz.uy' ]; config.server.hmr = false; config.resolve = config.resolve || {}; config.resolve.alias = { ...config.resolve.alias, '@dss/ui': path.join(__dirname, '../packages/dss-ui/src'), }; return config; }, };