Skip to content

Commit

Permalink
feat: add dynamic stylesheets imports in preview.js
Browse files Browse the repository at this point in the history
  • Loading branch information
robherba committed Sep 10, 2024
1 parent 618af65 commit e844a36
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import { useEffect } from '@storybook/preview-api';
import Twig from 'twig';
import { setupTwig } from './setupTwig';

// Project config to import stylesheets.
import('../../../../config/emulsify-core/storybook/preview');
try {
// Dynamically importing CSS files from the dist folder for Storybook preview.js.
const requireCSS = require.context("../../../../dist", true, /\.css$/);
requireCSS.keys().forEach(requireCSS);
} catch (error) {
console.warn(
'Warning: CSS files could not be loaded. The "dist" folder might be missing.',
);
}

// If in a Drupal project, it's recommended to import a symlinked version of drupal.js.
import './_drupal.js';
Expand Down

0 comments on commit e844a36

Please sign in to comment.