Storybook executors cannot find config files in certain cases
See original GitHub issueCurrent Behavior
The @nrwl/storybook:*
executors allow for specifying the options.config
object (which allows for defining configFolder
, configPath
, srcRoot
, and pluginPath
). When used in a target, running nx <target> <project-name>
will look for the paths defined in those configs, relative to where the command was run.
Example
libs/mylib/project.json snippet
{
"targets": {
"executor": "@nrwl/storybook:storybook",
"options": {
"config": {
"configFolder": "libs/mylib/.storybook"
}
}
}
}
Will yield the following results:
pwd
# outputs: /absolute/path/.../my-monorepo
nx serve mylib
# looks for the config file located at: /absolute/path/.../my-monorepo/libs/mylib/.storybook
cd libs/mylib
pwd
# outputs: /absolute/path/.../my-monorepo/libs/mylib
nx serve mylib
# looks for the config file located at: /absolute/path/.../my-monorepo/libs/mylib/libs/mylib/.storybook
This behavior is inconsistent with most repository-based tooling, as well as with other @nrwl executors, like Jest.
Expected Behavior
I expect to be able to run the Storybook-based targets/executors from any directory in the monorepo and have the configuration file resolve correctly with the same project.json file snippet provided above. Ideally, there would need to be no changes to my project.json file (to avoid breaking othersβ projects).
Steps to Reproduce
Failure Logs
> nx run mylib:serve --verbose
ENOENT: no such file or directory, stat 'libs/mylib/.storybook'
Error: ENOENT: no such file or directory, stat 'libs/mylib/.storybook'
at statSync (node:fs:1527:3)
at findOrCreateConfig (/Users/imyourmanzi/monorepo/node_modules/@nrwl/storybook/src/utils/utilities.js:106:50)
at resolveCommonStorybookOptionMapper (/Users/imyourmanzi/monorepo/node_modules/@nrwl/storybook/src/executors/utils.js:119:64)
at storybookOptionMapper (/Users/imyourmanzi/monorepo/node_modules/@nrwl/storybook/src/executors/storybook/storybook.impl.js:59:140)
at storybookExecutor_1 (/Users/imyourmanzi/monorepo/node_modules/@nrwl/storybook/src/executors/storybook/storybook.impl.js:12:24)
at storybookExecutor_1.next (<anonymous>)
at resume (/Users/imyourmanzi/monorepo/node_modules/tslib/tslib.js:225:48)
at fulfill (/Users/imyourmanzi/monorepo/node_modules/tslib/tslib.js:227:35)
βββββββββββββββββββββββββββββββββββββββββββββββ
> NX ERROR Running target "mylib:serve" failed
Environment
Node : 16.1.0
OS : darwin x64
npm : 7.11.2
nx : 13.4.6
@nrwl/angular : undefined
@nrwl/cli : 13.4.6
@nrwl/cypress : 13.4.6
@nrwl/devkit : 13.4.6
@nrwl/eslint-plugin-nx : 13.4.6
@nrwl/express : undefined
@nrwl/jest : 13.4.6
@nrwl/linter : 13.4.6
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : undefined
@nrwl/nx-cloud : undefined
@nrwl/react : 13.4.6
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/tao : 13.4.6
@nrwl/web : 13.4.6
@nrwl/workspace : 13.4.6
@nrwl/storybook : 13.4.6
@nrwl/gatsby : undefined
typescript : 4.5.5
rxjs : 6.6.7
---------------------------------------
Community plugins:
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Hi @imyourmanzi ! Thank you so much for filing an issue and providing a PR that solves it, too! I am reviewing your PR now, make sure all works as expected! π
Closing this for now! Let me know if we need to reopen!