Skip to content

fix: angular framework options#33190

Closed
arty-name wants to merge 2 commits into
storybookjs:nextfrom
arty-name:fix/angular-framework-options
Closed

fix: angular framework options#33190
arty-name wants to merge 2 commits into
storybookjs:nextfrom
arty-name:fix/angular-framework-options

Conversation

@arty-name
Copy link
Copy Markdown
Contributor

@arty-name arty-name commented Nov 26, 2025

Closes #31908

What I did

Added code to propagate the angularBuilderOptions from main.ts#framework.options to the options

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. Configure main.ts to include e.g.
  framework: {
    name: '@storybook/angular',
    options: {
      angularBuilderOptions: {
        styles: ['src/styles.css'],
      },
    },
  },
  1. Verify that styles is present in options.angularBuilderOptions

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Bug Fixes
    • Fixed merging of Angular builder options so CLI-provided settings properly override framework defaults and final build options are synchronized before target evaluation.

✏️ Tip: You can customize this high-level summary in your review settings.

@arty-name
Copy link
Copy Markdown
Contributor Author

While #31908 mentions two workarounds, one of them requires modification of the storybook file, and another needs storybook to be run through ng+angular.json. I run storybook as storybook dev and I can’t activate zoneless Angular via the main.ts#framework.options

@valentinpalkovic
Copy link
Copy Markdown
Contributor

valentinpalkovic commented Nov 26, 2025

Hi @arty-name

Thank you for your contribution.

angularBuilderOptions is not an option in the Storybook framework. Instead, the builder options have to be defined in your nx/angular.json's builder configuration for storybook and build-storybook. For more info: https://storybook.js.org/docs/get-started/frameworks/angular

@arty-name
Copy link
Copy Markdown
Contributor Author

Thank you for the prompt response, @valentinpalkovic!

I’ve finished writing my explanation of why ng+angular.json is not a good fit for my case right before your comment came in.

This PR doesn’t modify the core of storybook, only the Angular plugin, which already deals with angularBuilderOptions quite some. I’m just extending this a little more.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Nov 26, 2025

View your CI Pipeline Execution ↗ for commit b718d7a


☁️ Nx Cloud last updated this comment at 2025-12-08 16:03:16 UTC

@valentinpalkovic
Copy link
Copy Markdown
Contributor

valentinpalkovic commented Nov 26, 2025

Can you elaborate of why you're running storybook dev. This is discouraged when using @storybook/angular. I can imagine that you're poking around with Analog.js' Vite-based Storybook framework?

@arty-name
Copy link
Copy Markdown
Contributor Author

That’s the right guess! Our Angular projects use Vite for building, and Analog’s @analogjs/vite-plugin-angular and @analogjs/storybook-angular come in handy.

Using the standard storybook dev with them worked as a possible and more lightweight option.

@valentinpalkovic valentinpalkovic added bug angular ci:normal Run our default set of CI jobs (choose this for most PRs). labels Dec 1, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 1, 2025

📝 Walkthrough

Walkthrough

Merge framework-provided angularBuilderOptions into CLI-provided angularBuilderOptions inside getBuilderOptions when framework options contain entries, so framework values are deep-merged into the final options.angularBuilderOptions before explicit target options are evaluated. No public APIs changed.

Changes

Cohort / File(s) Summary
Angular CLI framework preset
code/frameworks/angular/src/server/framework-preset-angular-cli.ts
In getBuilderOptions, if options.frameworkOptions.angularBuilderOptions has keys, deep-merge it into options.angularBuilderOptions and assign back, so framework-provided angularBuilderOptions are incorporated prior to reading explicit target options.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review focus: getBuilderOptions merging logic and ensuring deepMerge semantics are correct and ordering (merge before target evaluation) is preserved.

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0c0e14 and b718d7a.

📒 Files selected for processing (1)
  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use ESLint and Prettier configurations that are enforced in the codebase

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Enable TypeScript strict mode

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
code/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{ts,tsx,js,jsx,mjs}: Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Use client-side logger from 'storybook/internal/client-logger' for browser code
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
code/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Export functions that need to be tested from their modules

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
code/**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier with --write flag to format code before committing
Run ESLint with yarn lint:js:cmd to check for linting issues and fix errors before committing

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (1)
code/frameworks/angular/src/server/framework-preset-angular-cli.ts (1)

133-140: angularBuilderOptions deep-merge and override order look correct

The new block correctly deep-merges frameworkOptions.angularBuilderOptions into options.angularBuilderOptions, using framework values as defaults and letting existing/CLI-provided options override them. This matches the intended behavior from the linked issue without introducing obvious runtime risks.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28fa98e and f0c0e14.

📒 Files selected for processing (1)
  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use ESLint and Prettier configurations that are enforced in the codebase

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Enable TypeScript strict mode

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
code/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{ts,tsx,js,jsx,mjs}: Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Use client-side logger from 'storybook/internal/client-logger' for browser code
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
code/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Export functions that need to be tested from their modules

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
code/**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier with --write flag to format code before committing
Run ESLint with yarn lint:js:cmd to check for linting issues and fix errors before committing

Files:

  • code/frameworks/angular/src/server/framework-preset-angular-cli.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: normal
  • GitHub Check: nx

Comment thread code/frameworks/angular/src/server/framework-preset-angular-cli.ts
@valentinpalkovic valentinpalkovic self-assigned this Dec 1, 2025
@github-actions github-actions Bot added the Stale label Dec 22, 2025
@valentinpalkovic
Copy link
Copy Markdown
Contributor

We are actively working on a @storybook/angular-vite framework, which will be based on Analog's Vite plugin infrastructure. Closing this PR in favour of the new framework, which should solve the issue holistically.

@arty-name
Copy link
Copy Markdown
Contributor Author

Great news, looking forward to this!

@arty-name arty-name deleted the fix/angular-framework-options branch March 10, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

angular bug ci:normal Run our default set of CI jobs (choose this for most PRs). Stale

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: framework.options.angularBuilderOptions in .storybook/main.ts is ignored and does not reach getBuilderOptions() in Angular integration

2 participants