@@ -481,45 +481,53 @@ export function addStorybookToNamedInputs(tree: Tree) {
481
481
}
482
482
}
483
483
484
- nxJson . targetDefaults ??= { } ;
485
- nxJson . targetDefaults [ 'build-storybook' ] ??= { } ;
486
- nxJson . targetDefaults [ 'build-storybook' ] . inputs ??= [
487
- 'default' ,
488
- hasProductionFileset ? '^production' : '^default' ,
489
- ] ;
484
+ updateNxJson ( tree , nxJson ) ;
485
+ }
486
+ }
490
487
491
- if (
492
- ! nxJson . targetDefaults [ 'build-storybook' ] . inputs . includes (
493
- '{projectRoot}/.storybook/**/*'
494
- )
495
- ) {
496
- nxJson . targetDefaults [ 'build-storybook' ] . inputs . push (
497
- '{projectRoot}/.storybook/**/*'
498
- ) ;
499
- }
488
+ export function addStorybookToTargetDefaults ( tree : Tree ) {
489
+ const nxJson = readNxJson ( tree ) ;
490
+
491
+ nxJson . targetDefaults ??= { } ;
492
+ nxJson . targetDefaults [ 'build-storybook' ] ??= { } ;
493
+ nxJson . targetDefaults [ 'build-storybook' ] . inputs ??= [
494
+ 'default' ,
495
+ nxJson . namedInputs && 'production' in nxJson . namedInputs
496
+ ? '^production'
497
+ : '^default' ,
498
+ ] ;
500
499
501
- // Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
502
- // because we want to rebuild Storybook if the .storybook folder changes
503
- const index = nxJson . targetDefaults [ 'build-storybook' ] . inputs . indexOf (
504
- '!{projectRoot}/.storybook/**/*'
500
+ if (
501
+ ! nxJson . targetDefaults [ 'build-storybook' ] . inputs . includes (
502
+ '{projectRoot}/.storybook/**/*'
503
+ )
504
+ ) {
505
+ nxJson . targetDefaults [ 'build-storybook' ] . inputs . push (
506
+ '{projectRoot}/.storybook/**/*'
505
507
) ;
508
+ }
506
509
507
- if ( index !== - 1 ) {
508
- nxJson . targetDefaults [ 'build-storybook' ] . inputs . splice ( index , 1 ) ;
509
- }
510
+ // Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
511
+ // because we want to rebuild Storybook if the .storybook folder changes
512
+ const index = nxJson . targetDefaults [ 'build-storybook' ] . inputs . indexOf (
513
+ '!{projectRoot}/.storybook/**/*'
514
+ ) ;
510
515
511
- if (
512
- ! nxJson . targetDefaults [ 'build-storybook' ] . inputs . includes (
513
- '{projectRoot}/tsconfig.storybook.json'
514
- )
515
- ) {
516
- nxJson . targetDefaults [ 'build-storybook' ] . inputs . push (
517
- '{projectRoot}/tsconfig.storybook.json'
518
- ) ;
519
- }
516
+ if ( index !== - 1 ) {
517
+ nxJson . targetDefaults [ 'build-storybook' ] . inputs . splice ( index , 1 ) ;
518
+ }
520
519
521
- updateNxJson ( tree , nxJson ) ;
520
+ if (
521
+ ! nxJson . targetDefaults [ 'build-storybook' ] . inputs . includes (
522
+ '{projectRoot}/tsconfig.storybook.json'
523
+ )
524
+ ) {
525
+ nxJson . targetDefaults [ 'build-storybook' ] . inputs . push (
526
+ '{projectRoot}/tsconfig.storybook.json'
527
+ ) ;
522
528
}
529
+
530
+ updateNxJson ( tree , nxJson ) ;
523
531
}
524
532
525
533
export function createProjectStorybookDir (
0 commit comments