Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(storybook): use build-storybook as a build target for all libs (#…
  • Loading branch information
mandarini committed Apr 1, 2022
1 parent 7fe6822 commit 43eee23
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/storybook/src/executors/utils.ts
Expand Up @@ -321,10 +321,17 @@ export function findStorybookAndBuildTargets(targets: {
if (targetConfig.executor === '@nrwl/storybook:build') {
returnObject.storybookBuildTarget = target;
}
if (
targetConfig.executor === '@angular-devkit/build-angular:browser' ||
targetConfig.executor === '@nrwl/angular:ng-packagr-lite'
) {
/**
* Not looking for '@nrwl/angular:ng-packagr-lite', only
* looking for '@angular-devkit/build-angular:browser'
* because the '@nrwl/angular:ng-packagr-lite' executor
* does not support styles and extra options, so the user
* will be forced to switch to build-storybook to add extra options.
*
* So we might as well use the build-storybook by default to
* avoid any errors.
*/
if (targetConfig.executor === '@angular-devkit/build-angular:browser') {
returnObject.buildTarget = target;
}
});
Expand Down
Expand Up @@ -225,6 +225,46 @@ describe('@nrwl/storybook:configuration', () => {
});
});

it('should update workspace file for angular buildable libs', async () => {
// Setup a new lib
await libraryGenerator(tree, {
name: 'test-ui-lib-5',
standaloneConfig: false,
buildable: true,
});
await configurationGenerator(tree, {
name: 'test-ui-lib-5',
uiFramework: '@storybook/angular',
standaloneConfig: false,
});
const project = readProjectConfiguration(tree, 'test-ui-lib-5');

expect(project.targets.storybook).toEqual({
executor: '@nrwl/storybook:storybook',
configurations: {
ci: {
quiet: true,
},
},
options: {
port: 4400,
projectBuildConfig: 'test-ui-lib-5:build-storybook',
uiFramework: '@storybook/angular',
config: {
configFolder: 'libs/test-ui-lib-5/.storybook',
},
},
});

expect(project.targets.lint).toEqual({
executor: '@nrwl/linter:eslint',
outputs: ['{options.outputFile}'],
options: {
lintFilePatterns: ['libs/test-ui-lib-5/**/*.ts'],
},
});
});

it('should update `tsconfig.lib.json` file', async () => {
await configurationGenerator(tree, {
name: 'test-ui-lib',
Expand Down

0 comments on commit 43eee23

Please sign in to comment.