Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular - Storybook fails on resolving stories from implementation directory #3053

Closed
Hotell opened this issue Feb 22, 2018 · 1 comment
Closed

Comments

@Hotell
Copy link

Hotell commented Feb 22, 2018

Issue details

Maybe I'm doing something wrong? But how can I properly load stories which are side by side with implementation of a particular component?

I'm using Angular CLI.

following doesn't work:

const req = require.context('../src/app', true, /\.stories\.ts$/);
req.keys().forEach((filename) => req(filename));

Steps to reproduce

Cannot load stories if they in the same folder with implementation:

// config.js
import { configure } from '@storybook/angular';
import { setOptions } from '@storybook/addon-options';

setOptions({
  hierarchyRootSeparator: /\|/,
});

function loadStories() {
  // put welcome screen at the top of the list so it's the first one displayed
  require('../src/stories');

  // automatically import all story ts files that end with *.stories.ts
  const req = require.context('../src/stories', true, /\.stories\.ts$/);
  req.keys().forEach((filename) => req(filename));

  // automatically import all story ts files that end with *.stories.ts within app ( side by side implementation )
  const reqLocal = require.context('../src/app', true, /\.stories\.ts$/);
  reqLocal.keys().forEach((filename) => req(filename));
}

configure(loadStories, module);

image

image

Please specify which version of Storybook and optionally any affected addons that you're running

  • @storybook/angular
  • @storybook/* 3.4.0-alpha.9
@Hotell
Copy link
Author

Hotell commented Feb 22, 2018

OMG ... sorry... typo

-reqLocal.keys().forEach((filename) => req(filename));
+reqLocal.keys().forEach((filename) => reqLocal(filename));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant