-
-
Notifications
You must be signed in to change notification settings - Fork 319
fix(vite-plugin-angular): remove duplicate hmr option #2204
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cb34426
fix(nx-plugin): order analog before tailwind plugin
benpsnyder ae795e6
fix(create-analog): order analog before tailwind plugin
benpsnyder 8fb2979
docs(vite-plugin-angular): align tailwind guidance with generated setup
benpsnyder 18799fc
docs: add PR review and description agent skills
brandonroberts 74617db
docs: add test coverage and build artifact checks to review-pr skill
brandonroberts 95387db
feat(platform): add generic style-pipeline hooks for community plugin…
benpsnyder e0df473
chore: release 3.0.0-alpha.26 [skip ci]
semantic-release-bot 2537f41
refactor: retire root tsconfig paths and move workspace linking to pa…
benpsnyder 20acf90
Merge branch 'alpha' into fix/tailwind-csr
benpsnyder 7a29bbc
fix: reorder plugins in generator configuration for improved compatib…
benpsnyder 874419d
docs: clarify Angular HMR requirements and compatibility for versions…
benpsnyder 4a7ec54
docs: update link format for HMR migration guidance in Tailwind integ…
benpsnyder e0b4fba
test: add coverage for analog registration in vite.config.ts templates
benpsnyder 3326eca
Merge remote-tracking branch 'origin/alpha' into fix/tailwind-csr
benpsnyder 94c2f5b
refactor: update Angular live-reload configuration and Tailwind integ…
benpsnyder 75ffacd
refactor: remove hmr compatibility alias and streamline live-reload c…
benpsnyder 87af10d
Merge branch 'alpha' into fix/tailwind-csr
brandonroberts 792e785
chore: update tsconfig path in live reload test
brandonroberts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| # Tailwind CSS v4 | ||
|
|
||
| Analog does not replace Tailwind's installation guides. Start with one Tailwind setup that matches your project: | ||
|
|
||
| - [Install Tailwind with Vite](https://tailwindcss.com/docs/installation/using-vite) | ||
| - [Install Tailwind with PostCSS](https://tailwindcss.com/docs/installation/using-postcss) | ||
| - [Install Tailwind with Angular](https://tailwindcss.com/docs/installation/framework-guides/angular) | ||
|
|
||
| Once Tailwind is installed, Analog adds the Angular-specific part: component stylesheet handling for `@apply` and Tailwind-aware `@reference` injection. | ||
|
|
||
| ## What Analog adds | ||
|
|
||
| Use Analog's `tailwindCss.rootStylesheet` option when you want Tailwind utilities inside Angular component styles. | ||
|
|
||
| That option lets Analog: | ||
|
|
||
| - detect component stylesheets that use Tailwind utilities | ||
| - inject the correct `@reference` to your root stylesheet | ||
| - keep component styles aligned with your root Tailwind theme, prefixes, and plugins | ||
| - avoid manual `@reference` directives in every component stylesheet | ||
|
|
||
| If you only use Tailwind utilities in templates and a global stylesheet, you can follow Tailwind's install docs and keep your generated scaffold defaults without adding extra Analog configuration. | ||
|
|
||
| ## Component Styles Setup | ||
|
|
||
| When you enable `tailwindCss.rootStylesheet`, keep Tailwind wired through Vite for the component stylesheet path: | ||
|
|
||
| ```ts | ||
| /// <reference types="vitest" /> | ||
|
|
||
| import { resolve } from 'node:path'; | ||
| import { defineConfig } from 'vite'; | ||
| import analog from '@analogjs/platform'; | ||
| import tailwindcss from '@tailwindcss/vite'; | ||
|
|
||
| export default defineConfig(() => ({ | ||
| plugins: [ | ||
| analog({ | ||
| vite: { | ||
| tailwindCss: { | ||
| rootStylesheet: resolve(__dirname, 'src/styles.css'), | ||
| }, | ||
| }, | ||
| }), | ||
| tailwindcss(), | ||
| ], | ||
| })); | ||
| ``` | ||
|
|
||
| If you are using `@analogjs/vite-plugin-angular` directly instead of `@analogjs/platform`, the same option lives on the Angular plugin: | ||
|
|
||
| ```ts | ||
| import { resolve } from 'node:path'; | ||
| import { defineConfig } from 'vite'; | ||
| import angular from '@analogjs/vite-plugin-angular'; | ||
| import tailwindcss from '@tailwindcss/vite'; | ||
|
|
||
| export default defineConfig(() => ({ | ||
| plugins: [ | ||
| angular({ | ||
| tailwindCss: { | ||
| rootStylesheet: resolve(__dirname, 'src/styles.css'), | ||
| }, | ||
| }), | ||
| tailwindcss(), | ||
| ], | ||
| })); | ||
| ``` | ||
|
|
||
| List `analog()` before `tailwindcss()` in your Vite config. Current generators now scaffold that order. | ||
|
|
||
| ## Root Stylesheet | ||
|
|
||
| In `src/styles.css`: | ||
|
|
||
| ```css | ||
| @import 'tailwindcss'; | ||
| ``` | ||
|
|
||
| You can keep your theme, `@source`, plugins, and prefixes there as well: | ||
|
|
||
| ```css | ||
| @import 'tailwindcss' prefix(tw); | ||
|
|
||
| @source './src'; | ||
|
|
||
| @theme { | ||
| --color-primary: #3b82f6; | ||
| } | ||
| ``` | ||
|
|
||
| Use an absolute `rootStylesheet` path. Analog may serve component styles through virtual stylesheet ids during dev, so relative `@reference` paths are not reliable there. | ||
|
|
||
| ## How Component Styles Work | ||
|
|
||
| Angular compiles component styles in isolation. When a component stylesheet contains `@apply`, Tailwind still needs access to the root stylesheet that defines prefixes, theme values, and plugins. | ||
|
|
||
| Analog handles that by: | ||
|
|
||
| - detecting Tailwind usage in component CSS | ||
| - injecting `@reference` to the configured root stylesheet | ||
| - routing those component styles through the Vite CSS pipeline when needed | ||
|
|
||
| That means you should not manually add `@reference` to every component stylesheet in the normal setup. | ||
|
|
||
| ## Prefixes | ||
|
|
||
| If your component styles use custom-prefixed utilities, configure `prefixes` so Analog knows which stylesheets need Tailwind `@reference` injection: | ||
|
|
||
| ```ts | ||
| analog({ | ||
| vite: { | ||
| tailwindCss: { | ||
| rootStylesheet: resolve(__dirname, 'src/styles.css'), | ||
| prefixes: ['tw:'], | ||
| }, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| Without `prefixes`, Analog falls back to its default Tailwind usage detection for component styles. | ||
|
|
||
| ## HMR | ||
|
|
||
| Use `liveReload` when you need to configure Analog's Angular live-reload behavior explicitly. | ||
|
|
||
| Vite's `server.hmr` option is separate. It controls the HMR websocket transport, so you can use `server.hmr` together with `liveReload` when your dev server needs custom host, port, or path settings. | ||
|
|
||
| Angular HMR requires Angular v19 or newer. On Angular v17-v18, `liveReload` is intentionally disabled at runtime and emits a console warning, so HMR is unavailable on those versions. For broader migration guidance, see the [migration guide](/docs/guides/migrating). | ||
|
|
||
| Tailwind support does not require you to enable HMR manually. The stylesheet pipeline is handled independently from whether Angular can produce a hot component update for a given edit. | ||
|
|
||
| ## Generated Apps | ||
|
|
||
| Current `create-analog` and Nx app scaffolds already: | ||
|
|
||
| - import Tailwind in `src/styles.css` | ||
| - register Tailwind in `vite.config.ts` | ||
| - keep the generated Vite plugin order aligned with the current Analog templates | ||
|
|
||
| Some templates may also include additional Tailwind tooling config files. Treat the generated scaffold as your project default, and only diverge after validating your own dev and build behavior. | ||
|
|
||
| ## Related | ||
|
|
||
| - [Using CSS Pre-processors](/docs/packages/vite-plugin-angular/css-preprocessors) | ||
| - [create-analog](/docs/packages/create-analog/overview) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should flow through the analog plugin to the Vite plugin.