You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docs-app/docs/guides/migrating-v2-to-v3.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,4 +158,4 @@ Keep automated migration tooling focused on the breaking changes above:
158
158
- rewrite only the legacy `@analogjs/vite-plugin-angular/setup-vitest` setup import
159
159
- flag `@analogjs/trpc` as a removed package that needs a manual migration plan
160
160
- flag `experimental.useAnalogCompiler`, `analogCompilationMode`, and `@analogjs/angular-compiler` as unsupported on the current v3 alpha line rather than removed outright
161
-
- treat optional helpers such as `withTypedRouter`, `withRouteContext`, `withLoaderCaching`, `withDebugRoutes`, and compatibility aliases such as `liveReload` as opt-in rather than mandatory rewrites
161
+
- treat optional helpers such as `withTypedRouter`, `withRouteContext`, `withLoaderCaching`, `withDebugRoutes`, and compatibility aliases such as `hmr` as opt-in rather than mandatory rewrites
Angular supports HMR where in most cases components can be updated without a full page reload. In Analog, prefer the `hmr` option. `liveReload` is still accepted as a compatibility alias, but `hmr` is the primary API.
194
-
Analog requires Angular v19 or newer for `hmr` / `liveReload` to work. On Angular v17-v18, `hmr` and its `liveReload` alias are forcibly disabled at runtime with a console warning, so HMR is unavailable on those versions.
193
+
Angular supports HMR where in most cases components can be updated without a full page reload. In Analog, use `liveReload` to control the Angular live-reload pipeline.
194
+
195
+
This is separate from Vite's `server.hmr` option, which configures the HMR websocket transport. You can use `server.hmr` together with `liveReload` when you need custom host, port, or path settings. `hmr` is still accepted as a compatibility alias for `liveReload`.
196
+
197
+
Analog requires Angular v19 or newer for `liveReload` / `hmr` to work. On Angular v17-v18, `liveReload` and its `hmr` alias are forcibly disabled at runtime with a console warning, so HMR is unavailable on those versions.
For current Analog projects, prefer `framework.options.hmr` if you need to configure Angular HMR. `liveReload` is still accepted as a compatibility alias, but `hmr` is the recommended option.
94
+
For current Analog projects, use `framework.options.liveReload` to control Analog's Angular live-reload behavior.
95
+
96
+
This is separate from Vite's `server.hmr` option, which configures the HMR websocket transport. You can use `server.hmr` together with `framework.options.liveReload` when Storybook needs custom host, port, or path settings. `framework.options.hmr` is still accepted as a compatibility alias.
95
97
96
98
Remove the existing `webpackFinal` config function if present.
97
99
@@ -148,7 +150,7 @@ If your project uses Tailwind v4, keep Storybook aligned with the same opinionat
148
150
- one root stylesheet such as `src/styles.css`
149
151
-`@import 'tailwindcss';` in that stylesheet
150
152
-`framework.options.tailwindCss.rootStylesheet` pointing at that stylesheet
151
-
-`framework.options.hmr` for Angular HMR behavior
153
+
-`framework.options.liveReload` for Angular reload behavior
Copy file name to clipboardExpand all lines: apps/docs-app/docs/integrations/tailwind/index.md
+38-57Lines changed: 38 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,29 @@
1
1
# Tailwind CSS v4
2
2
3
-
Analog supports Tailwind CSS v4 for both:
3
+
Analog does not replace Tailwind's installation guides. Start with one Tailwind setup that matches your project:
4
4
5
-
- utility classes in templates
6
-
-`@apply` inside Angular component styles
5
+
-[Install Tailwind with Vite](https://tailwindcss.com/docs/installation/using-vite)
6
+
-[Install Tailwind with PostCSS](https://tailwindcss.com/docs/installation/using-postcss)
7
+
-[Install Tailwind with Angular](https://tailwindcss.com/docs/installation/framework-guides/angular)
7
8
8
-
The supported v3 `alpha` setup is:
9
+
Once Tailwind is installed, Analog adds the Angular-specific part: component stylesheet handling for `@apply` and Tailwind-aware `@reference` injection.
9
10
10
-
1. keep one root stylesheet such as `src/styles.css`
11
-
2. put `@import 'tailwindcss';` in that stylesheet
12
-
3. enable `@tailwindcss/vite` in `vite.config.ts`
13
-
4. keep a `postcss.config.mjs` with `@tailwindcss/postcss`
14
-
5. configure Analog with `tailwindCss.rootStylesheet`
11
+
## What Analog adds
15
12
16
-
Generated apps already follow this shape.
13
+
Use Analog's `tailwindCss.rootStylesheet` option when you want Tailwind utilities inside Angular component styles.
- detect component stylesheets that use Tailwind utilities
18
+
- inject the correct `@reference` to your root stylesheet
19
+
- keep component styles aligned with your root Tailwind theme, prefixes, and plugins
20
+
- avoid manual `@reference` directives in every component stylesheet
21
+
22
+
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.
23
23
24
-
## Vite Config
24
+
## Component Styles Setup
25
+
26
+
When you enable `tailwindCss.rootStylesheet`, keep Tailwind wired through Vite for the component stylesheet path:
Use an absolute `rootStylesheet` path. Analog may serve component styles through virtual stylesheet ids during dev, so relative `@reference` paths are not reliable there.
49
-
50
-
If you are using `@analogjs/vite-plugin-angular` directly instead of `@analogjs/platform`, the same Tailwind option lives on the Angular plugin itself:
50
+
If you are using `@analogjs/vite-plugin-angular` directly instead of `@analogjs/platform`, the same option lives on the Angular plugin:
List `analog()` before `tailwindcss()` in your Vite config. Current generators now scaffold that order.
71
+
70
72
## Root Stylesheet
71
73
72
74
In `src/styles.css`:
@@ -87,19 +89,7 @@ You can keep your theme, `@source`, plugins, and prefixes there as well:
87
89
}
88
90
```
89
91
90
-
## PostCSS Config
91
-
92
-
Create `postcss.config.mjs`:
93
-
94
-
```js
95
-
export default {
96
-
plugins: {
97
-
'@tailwindcss/postcss': {},
98
-
},
99
-
};
100
-
```
101
-
102
-
Keep this even if dev already works with `@tailwindcss/vite`. Current Analog builds still rely on the PostCSS path for production CSS processing.
92
+
Use an absolute `rootStylesheet` path. Analog may serve component styles through virtual stylesheet ids during dev, so relative `@reference` paths are not reliable there.
103
93
104
94
## How Component Styles Work
105
95
@@ -108,30 +98,11 @@ Angular compiles component styles in isolation. When a component stylesheet cont
108
98
Analog handles that by:
109
99
110
100
- detecting Tailwind usage in component CSS
111
-
- injecting the correct `@reference` to the configured root stylesheet
112
-
- externalizing component styles during dev when needed so they flow through Vite's CSS pipeline
113
-
- preserving the build path through PostCSS for production
101
+
- injecting `@reference` to the configured root stylesheet
102
+
- routing those component styles through the Vite CSS pipeline when needed
114
103
115
104
That means you should not manually add `@reference` to every component stylesheet in the normal setup.
116
105
117
-
## Plugin Order
118
-
119
-
List `analog()` before `tailwindcss()` in your Vite config. That is now how the generators scaffold it.
This keeps the config aligned with the generated apps and the current documentation.
126
-
127
-
## HMR
128
-
129
-
Prefer `hmr` over `liveReload` when you need to configure Angular HMR explicitly. `liveReload` remains a compatibility alias.
130
-
131
-
Angular HMR requires Angular v19 or newer. On Angular v16-v18, `hmr` and `liveReload` are intentionally disabled at runtime and emit a console warning, so HMR is unavailable on those versions. For the broader migration guidance, see [Enabling HMR](/docs/guides/migrating#enabling-hmr).
132
-
133
-
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.
134
-
135
106
## Prefixes
136
107
137
108
If your component styles usecustom-prefixed utilities, configure `prefixes` so Analog knows which stylesheets need Tailwind `@reference` injection:
@@ -149,15 +120,25 @@ analog({
149
120
150
121
Without `prefixes`, Analog falls back to its default Tailwind usage detection for component styles.
151
122
123
+
## HMR
124
+
125
+
Use `liveReload` when you need to configure Analog's Angular live-reload behavior explicitly.
126
+
127
+
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. `hmr` is still accepted as a compatibility alias for `liveReload`.
128
+
129
+
Angular HMR requires Angular v19 or newer. On Angular v17-v18, `liveReload` and its `hmr` alias are intentionally disabled at runtime and emit a console warning, so HMR is unavailable on those versions. For broader migration guidance, see the [migration guide](/docs/guides/migrating).
130
+
131
+
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.
132
+
152
133
## Generated Apps
153
134
154
-
Current `create-analog` and Nx app scaffolds both generate:
135
+
Current `create-analog` and Nx app scaffolds already:
155
136
156
-
-`@import 'tailwindcss';` in `src/styles.css`
157
-
-`@tailwindcss/vite` in `vite.config.ts`
158
-
-`postcss.config.mjs`with `@tailwindcss/postcss`
137
+
- import Tailwind in `src/styles.css`
138
+
-register Tailwind in `vite.config.ts`
139
+
-keep the generated Vite plugin order aligned with the current Analog templates
159
140
160
-
If you start from a generated app, keep that structure unless you have a specific reason to diverge from the supported path.
141
+
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.
Copy file name to clipboardExpand all lines: apps/docs-app/docs/packages/create-analog/overview.md
+3-7Lines changed: 3 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,15 +47,11 @@ pnpm create analog
47
47
48
48
### Tailwind v4
49
49
50
-
`create-analog` scaffolds Tailwind v4 with the current supported Analog setup. Generated projects include:
50
+
`create-analog` scaffolds Tailwind v4 for the current Analog templates. Generated projects import Tailwind in `src/styles.css` and wire the Tailwind-related Vite config the template expects.
51
51
52
-
- one root stylesheet, usually `src/styles.css`, with `@import 'tailwindcss';`
53
-
-`@tailwindcss/vite` in `vite.config.ts`
54
-
-`postcss.config.mjs` with `@tailwindcss/postcss`
52
+
If you only need Tailwind utilities in templates and global styles, keep the scaffold defaults.
55
53
56
-
Analog then handles component-level `@reference` injection through its Tailwind-aware stylesheet pipeline, so you do not need to add `@reference` directives manually to every component stylesheet.
57
-
58
-
For the full Tailwind v4 setup and behavior details, see the [Tailwind CSS integration guide](/docs/integrations/tailwind).
54
+
If you also want `@apply` inside Angular component styles, add Analog's `tailwindCss.rootStylesheet` option and follow the [Tailwind CSS guide](/docs/integrations/tailwind).
59
55
60
56
If you do not want Tailwind in the generated app, pass `--skipTailwind true`. The default Tailwind v4 flow expects a plain CSS entry file for global styles.
The Vite Plugin supports CSS pre-processing using external `styleUrls` and inline `styles` in the Component decorator metadata.
6
6
7
-
## Recommended Tailwind v4 setup
7
+
## Tailwind v4 component styles
8
8
9
-
If your app uses Tailwind v4, keep the supported Analog setup:
9
+
Tailwind installation itself should follow Tailwind's docs. The Analog-specific configuration below is for Angular component styles that use Tailwind utilities such as `@apply`.
10
10
11
11
- keep a single root stylesheet such as `src/styles.css`
12
12
- put `@import 'tailwindcss';` in that root stylesheet
13
13
- keep `@tailwindcss/vite` enabled in `vite.config.ts`
14
-
- keep `postcss.config.mjs` with `@tailwindcss/postcss`
15
14
- configure Analog with `tailwindCss.rootStylesheet`
16
15
17
16
This lets Analog preprocess component stylesheets and inject the correct `@reference` directive automatically for component CSS that uses Tailwind utilities.
18
17
19
-
For the complete setup and Tailwind-specific guidance, see the [Tailwind CSS integration guide](/docs/integrations/tailwind).
18
+
For the broader Tailwind + Analog overview, see the [Tailwind CSS guide](/docs/integrations/tailwind).
Use an absolute path for `rootStylesheet`. Analog serves some component styles through virtual stylesheet ids during dev, so relative `@reference` paths are not reliable there.
59
48
49
+
Use `liveReload` to control Analog's Angular reload behavior. Vite's top-level `server.hmr` option remains available when you need to configure the HMR websocket transport separately.
50
+
60
51
You only need `tailwindCss.prefixes` when your component styles use custom-prefixed utilities and you want Analog to look for those prefixes instead of the default `@apply` detection.
61
52
53
+
If you only use Tailwind utilities in templates and a global stylesheet, you can keep your Tailwind install path and skip `tailwindCss.rootStylesheet`.
54
+
62
55
External `styleUrls` can be used without any additional configuration.
@@ -123,7 +123,9 @@ In your global stylesheet, import Tailwind with:
123
123
124
124
Storybook does not automatically infer the Tailwind plugin from your app's `vite.config.ts`, so add it in `viteFinal` when your stories depend on Tailwind utilities.
125
125
126
-
Angular HMR is controlled with `framework.options.hmr`. `liveReload` is still accepted as a compatibility alias, but `hmr` is the preferred option.
126
+
Angular reload behavior is controlled with `framework.options.liveReload`.
127
+
128
+
This is separate from Vite's `server.hmr` option, which configures the HMR websocket transport. You can use `server.hmr` together with `framework.options.liveReload` when Storybook needs custom host, port, or path settings. `framework.options.hmr` is still accepted as a compatibility alias.
0 commit comments