snappy-prerender 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +122 -101
- package/docs/limitations.md +58 -0
- package/docs/react-snap-migration.md +45 -0
- package/docs/report.md +102 -0
- package/package.json +2 -1
- package/src/cli-init.js +205 -0
- package/src/cli.js +73 -168
- package/src/core/artifacts.js +2 -0
- package/src/core/audit/index.js +114 -0
- package/src/core/audit/links.js +63 -0
- package/src/core/audit/metadata.js +88 -0
- package/src/core/audit/sitemap.js +39 -0
- package/src/core/config.js +129 -5
- package/src/core/crawl.js +300 -0
- package/src/core/csp.js +127 -0
- package/src/core/frameworks.js +94 -0
- package/src/core/hydration-diff.js +93 -0
- package/src/core/init.js +143 -30
- package/src/core/normalize.js +7 -0
- package/src/core/page-meta.js +108 -0
- package/src/core/preload-links.js +120 -0
- package/src/core/render.js +87 -5
- package/src/core/report.js +108 -0
- package/src/core/resources.js +5 -1
- package/src/core/route-config.js +17 -0
- package/src/core/route-sources.js +209 -0
- package/src/core/run.js +68 -113
- package/src/core/sitemap.js +90 -14
- package/src/core/verify.js +92 -48
- package/src/core/write.js +92 -7
- package/src/head/index.js +2 -2
- package/src/head/manager.js +54 -13
- package/src/head/tags.js +52 -6
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,57 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Earlier history predates
|
|
7
7
|
the release tags; see the Git history for those changes.
|
|
8
8
|
|
|
9
|
+
## [2.7.0] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Site audit for route health, links, metadata, sitemap and CSP. Findings are report-only
|
|
14
|
+
unless `failOnAuditError` is set; `auditIgnoreLinks` excludes dynamic links.
|
|
15
|
+
- `reportPath` / `--report` writes a versioned JSON report with per-route records, audit,
|
|
16
|
+
verification, sitemap, preload manifest, truncation and traces.
|
|
17
|
+
- `routesFile` and `routesFromSitemap` seed routes from text, JSON or a sitemap. Sitemap
|
|
18
|
+
indexes are followed one level, and relative paths resolve against the config file.
|
|
19
|
+
- Deterministic BFS crawling when `maxRoutes` or `routePriority` is set.
|
|
20
|
+
`truncated.droppedRoutes` lists the routes that did not fit.
|
|
21
|
+
- `routeOverrides` for per-route timeout, wait, readiness, crawl and storage state.
|
|
22
|
+
- `transformHtml`, sync or async, runs before preload and CSP injection.
|
|
23
|
+
- Framework detection for React, Vue, Svelte and Preact, with framework-specific hydration
|
|
24
|
+
messages and `firstMismatch` details.
|
|
25
|
+
- `preloadLinks` for runtime chunks, fonts and the LCP image.
|
|
26
|
+
- Sitemap hreflang alternates, image entries and `sitemap.locs` in the report.
|
|
27
|
+
- Head JSON-LD, `lang`/`dir` and hreflang alternates.
|
|
28
|
+
- App-declared 404 pages via `<meta name="prerender-status-code" content="404">`.
|
|
29
|
+
- `csp: 'hash'` adds a meta policy with SHA-256 hashes for inline scripts and styles.
|
|
30
|
+
- `retries`, `retryDelay` and `traceOnError` for failed renders.
|
|
31
|
+
- `init` migration for a legacy `reactSnap` block.
|
|
32
|
+
- CLI flags and documentation for the new options.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Verification reports the detected framework and uses its hydration message patterns.
|
|
37
|
+
- SVG `<title>` elements are no longer counted as page titles.
|
|
38
|
+
- Page metadata, audit findings and sitemap entries use the final HTML after transform and
|
|
39
|
+
preload injection.
|
|
40
|
+
- Route sources resolve relative paths against the config file. Sitemap base and origin
|
|
41
|
+
handling is stricter.
|
|
42
|
+
- The JSON report includes the verification summary, uses crawl acceptance order for
|
|
43
|
+
`order`, and redacts credentials, query strings and the storage-state path.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- A configured `notFoundRoute` may return HTTP 404 and is still written as `404.html`;
|
|
48
|
+
verification accepts that status for the same route.
|
|
49
|
+
- An explicit `framework` selects its hydration message patterns during verification.
|
|
50
|
+
- A non-string `transformHtml` result fails that route with a clear error.
|
|
51
|
+
- `routeOverrides` ignores undefined values instead of clearing base settings.
|
|
52
|
+
- `audit.linksChecked` counts every link pair considered, and route-health findings are
|
|
53
|
+
included in the audit.
|
|
54
|
+
- `preloadLinks` does not preload scripts removed by `removeScriptTags` or `transformHtml`.
|
|
55
|
+
- CSP hash mode warns when the generated policy blocks a browser request.
|
|
56
|
+
- `init` normalises a single-string `reactSnap.include`.
|
|
57
|
+
- The image sitemap collects `srcset` and `<picture><source>` candidates.
|
|
58
|
+
- New no-op option combinations produce configuration warnings.
|
|
59
|
+
|
|
9
60
|
## [2.6.0] - 2026-10-27
|
|
10
61
|
|
|
11
62
|
### Added
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# snappy-prerender
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Render a single-page app to static HTML at build time. Point the tool at the build output; it renders each route in Chrome, writes one HTML file per route, and leaves the app unchanged. The output includes page content, titles, meta tags, canonical links and Open Graph tags.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/snappy-prerender)
|
|
6
6
|
[](https://www.npmjs.com/package/snappy-prerender)
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
Package page: [npmjs.com/package/snappy-prerender](https://www.npmjs.com/package/snappy-prerender). Install with `npm install --save-dev snappy-prerender`. Release notes are in [CHANGELOG.md](CHANGELOG.md).
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
12
|
+
- No SSR entry, framework migration or app changes. If the app builds to a directory, it can be prerendered.
|
|
13
|
+
- React 16.8, 17, 18 and 19, Vite 6/7/8, or any static build.
|
|
14
|
+
- Based on the react-snap approach, reimplemented for current toolchains with Playwright and a hydration check.
|
|
15
15
|
|
|
16
16
|
## Who this is for
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Use it for client-rendered apps that need crawler-visible HTML: Create React App, Vite + React, other SPAs, CMS-backed sites and client-routed marketing pages.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Do not use it for apps that already render HTML on the server, such as Next.js, Remix or Astro.
|
|
21
21
|
|
|
22
22
|
## Quick start
|
|
23
23
|
|
|
@@ -81,41 +81,41 @@ if (!report.ok) {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
##
|
|
84
|
+
## Based on react-snap
|
|
85
85
|
|
|
86
|
-
react-snap
|
|
86
|
+
[react-snap](https://github.com/stereobooster/react-snap) showed that a browser and a build step can produce crawler-readable HTML without a server renderer. It has been unmaintained since 2019.
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
snappy-prerender reimplements that approach; no react-snap code is reused. It uses Playwright, resolves an installed Chrome or Edge, supports Vite, ships a head layer, and verifies hydration.
|
|
89
89
|
|
|
90
|
-
If you are moving over,
|
|
90
|
+
If you are moving over, [Migrating from react-snap](docs/react-snap-migration.md) maps the options.
|
|
91
91
|
|
|
92
92
|
## What you get
|
|
93
93
|
|
|
94
94
|
| | |
|
|
95
95
|
| --- | --- |
|
|
96
|
-
| **Static HTML per route** | `route/index.html` (or `route.html` with `flatOutput`), plus
|
|
97
|
-
| **Head and metadata** |
|
|
98
|
-
| **Hydration report** |
|
|
99
|
-
| **
|
|
100
|
-
| **Output optimisation** | Critical CSS, HTML/CSS minification, preconnect hints, image preload, a preload manifest, script and style
|
|
101
|
-
| **CSS-in-JS support** | CSSOM-only styles
|
|
102
|
-
| **Ajax state replay** | Captured JSON and `window.snapSaveState()` are injected before the first script
|
|
103
|
-
| **Guided setup** | `snappy-prerender init`
|
|
104
|
-
| **Any static build** | Base paths, `serveCmd
|
|
96
|
+
| **Static HTML per route** | `route/index.html` (or `route.html` with `flatOutput`), plus `404.html`. Identical files are left untouched. |
|
|
97
|
+
| **Head and metadata** | Per-route title, description, robots, canonical, Open Graph and Twitter tags, updated on client-side navigation. |
|
|
98
|
+
| **Hydration report** | Each route is reloaded with the real bundle and reported as `hydrated`, `re-rendered`, `undetected` or `unknown`, with mismatch messages. |
|
|
99
|
+
| **Ready contract** | `window.__prerenderReady`, a selector, or network quiescence. |
|
|
100
|
+
| **Output optimisation** | Critical CSS, HTML/CSS minification, preconnect hints, image preload, a preload manifest, script and style removal. |
|
|
101
|
+
| **CSS-in-JS support** | CSSOM-only styles and constructable stylesheets are written back into the HTML. |
|
|
102
|
+
| **Ajax state replay** | Captured JSON and `window.snapSaveState()` are injected before the first script. |
|
|
103
|
+
| **Guided setup** | `snappy-prerender init` writes a `snappy.config.js` from the project settings and a few answers. |
|
|
104
|
+
| **Any static build** | Base paths, `serveCmd`, screenshots, dry runs and bounded concurrency. |
|
|
105
105
|
|
|
106
106
|
## How it works
|
|
107
107
|
|
|
108
|
-
1. Serves the built output on an ephemeral loopback port
|
|
109
|
-
2. Crawls same-origin links from the seed routes
|
|
110
|
-
3. Waits for the
|
|
111
|
-
4. Freezes CSS animations, optionally blocks third-party requests, records
|
|
112
|
-
5. Serialises the DOM
|
|
113
|
-
6. Writes `route/index.html`
|
|
114
|
-
7. Reloads
|
|
108
|
+
1. Serves the built output on an ephemeral loopback port, or copies it to `destination`.
|
|
109
|
+
2. Crawls same-origin links from the seed routes in a fresh browser context per page.
|
|
110
|
+
3. Waits for the ready contract, quiet network, fonts and two animation frames.
|
|
111
|
+
4. Freezes CSS animations, optionally blocks third-party requests, records resources and reconciles head tags.
|
|
112
|
+
5. Serialises the DOM and post-processes it: removes freeze styles and `data-prerender-remove` elements, de-duplicates head styles, drops dead blob stylesheets, adds link hints, optionally inlines CSS, removes or marks scripts, optionally minifies, and records metadata issues.
|
|
113
|
+
6. Writes `route/index.html` or a screenshot, leaving identical files untouched.
|
|
114
|
+
7. Reloads each written file with the client bundle and reports hydration errors and boot mode.
|
|
115
115
|
|
|
116
116
|
## Head and metadata
|
|
117
117
|
|
|
118
|
-
Per-route titles, descriptions, canonical links and Open Graph/Twitter tags come from
|
|
118
|
+
Per-route titles, descriptions, canonical links and Open Graph/Twitter tags come from the package's `Head` component. It updates the document head on every render, including client-side navigation, and the prerenderer captures the result.
|
|
119
119
|
|
|
120
120
|
```jsx
|
|
121
121
|
import { Head } from 'snappy-prerender/head';
|
|
@@ -127,11 +127,18 @@ import { Head } from 'snappy-prerender/head';
|
|
|
127
127
|
type="article"
|
|
128
128
|
locale="en_GB"
|
|
129
129
|
robots="index,follow"
|
|
130
|
+
lang="en"
|
|
131
|
+
dir="ltr"
|
|
132
|
+
structuredData={{ '@context': 'https://schema.org', '@type': 'WebPage', name: 'Awards' }}
|
|
133
|
+
alternates={[
|
|
134
|
+
{ hreflang: 'en', href: '/awards' },
|
|
135
|
+
{ hreflang: 'x-default', href: '/awards' },
|
|
136
|
+
]}
|
|
130
137
|
extra={[{ name: 'keywords', content: 'polymer' }, { rel: 'alternate', href: '/feed.xml' }]}
|
|
131
138
|
/>
|
|
132
139
|
```
|
|
133
140
|
|
|
134
|
-
Project-wide values come from the `metadata` option. The prerenderer injects them into every page, so the component
|
|
141
|
+
Project-wide values come from the `metadata` option. The prerenderer injects them into every page, so the component builds absolute URLs from the public site instead of the build server:
|
|
135
142
|
|
|
136
143
|
```js
|
|
137
144
|
snappy({
|
|
@@ -147,44 +154,68 @@ snappy({
|
|
|
147
154
|
|
|
148
155
|
What it emits, per route: `title` (with the template applied unless the title already carries its suffix), `meta[name=description]`, `meta[name=robots]`, `link[rel=canonical]`, `og:title`, `og:description`, `og:type`, `og:url`, `og:image`, `og:site_name`, `og:locale`, and `twitter:card` / `twitter:title` / `twitter:description` / `twitter:image`. Switch a family off with `openGraph: false` or `twitter: false`, and skip the canonical with `canonical: false`.
|
|
149
156
|
|
|
150
|
-
Rules
|
|
151
|
-
|
|
152
|
-
-
|
|
153
|
-
-
|
|
154
|
-
-
|
|
155
|
-
-
|
|
156
|
-
- The
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
- `
|
|
160
|
-
-
|
|
157
|
+
Rules:
|
|
158
|
+
- `metadata` values are defaults; a `Head` prop wins. When several Heads render, the last one wins per tag.
|
|
159
|
+
- Tags are matched by the attribute a crawler reads, so existing tags are updated instead of duplicated. Duplicate identities are reduced to one.
|
|
160
|
+
- Generated tags carry `data-snappy-head-created` beside `data-snappy-head`, so a later page load can tell them from tags the app wrote.
|
|
161
|
+
- When no Head wants a tag, a generated one is removed and an app-written one is restored to its previous value. That original is recorded in the page during prerendering.
|
|
162
|
+
- The component renders nothing, so it does not affect hydration of page content.
|
|
163
|
+
- The title template is skipped when the title already ends with its fixed part, or is the site name, so a hand-built title is not suffixed twice.
|
|
164
|
+
- `structuredData` emits `<script type="application/ld+json">` for one object or an array, keyed per mounted `Head`. Values are escaped; add `@context` when needed.
|
|
165
|
+
- `lang` and `dir` are written on `<html>`. Later Heads win, and the original values return when no Head wants them.
|
|
166
|
+
- `alternates` emits `<link rel="alternate" hreflang="...">` with absolute URLs using the same `siteUrl`/`base`/`trailingSlash` policy as canonical links. The same alternates feed sitemap `xhtml:link` entries.
|
|
167
|
+
- `og:url`, `og:image` and canonical need absolute URLs. `metadata.siteUrl` must be an origin; put a sub-path deployment in `base`. Without `siteUrl`, build-server URLs are removed by default and the run warns. `trailingSlash` applies to page URLs only. Canonical, social and sitemap URLs share the page-path policy: directory output keeps its slash, flat output stays extensionless, and `trailingSlash` wins.
|
|
168
|
+
- `metadata.base` overrides the base path for absolute URLs and defaults to `base`.
|
|
169
|
+
- On React 19, React also hoists `<title>` and `<meta>` from JSX and leaves an existing template title alone, which can produce two titles. Use one metadata system; the run warns when a page has more than one `<title>`.
|
|
161
170
|
- Every metadata value has a CLI flag: `--metadata-site-url`, `--metadata-site-name`, `--metadata-title-template`, `--metadata-default-image`, `--metadata-trailing-slash`.
|
|
162
|
-
- `react` is an optional peer dependency
|
|
171
|
+
- `react` is an optional peer dependency for this entry point. Non-React code can call `setHead(id, props)` and `clearHead(id)`.
|
|
172
|
+
|
|
173
|
+
## Audit, reports and route sources
|
|
174
|
+
|
|
175
|
+
The audit runs by default and reports:
|
|
176
|
+
|
|
177
|
+
- route errors, truncation, empty or duplicate output, broken internal links;
|
|
178
|
+
- duplicate or missing metadata, canonical mismatches, heading counts, sitemap disagreement and orphan pages;
|
|
179
|
+
- CSP violations reported by the browser.
|
|
180
|
+
|
|
181
|
+
Findings are returned in `report.audit` and logged. They do not fail the run unless `failOnAuditError` is true. `auditIgnoreLinks` excludes dynamic links, and `--no-audit` skips the audit. See [docs/report.md](docs/report.md) for the rule list and JSON schema.
|
|
182
|
+
|
|
183
|
+
`reportPath` (or `--report`) writes the report as versioned JSON. URLs are reduced to origin and path, and the storage-state path is redacted.
|
|
184
|
+
|
|
185
|
+
Routes can come from `include` and crawling, from a text/JSON `routesFile`, or from a local or remote sitemap via `routesFromSitemap`. Relative source paths resolve against the config file. Root-relative sitemap locations have `base` stripped, and a remote sitemap's off-origin locations are ignored. If either source is supplied and `include` is not set, the root is not seeded implicitly. With `maxRoutes` or `routePriority`, crawling runs in deterministic breadth-first waves sorted by priority then path. `truncated.droppedRoutes` lists routes that did not fit.
|
|
186
|
+
|
|
187
|
+
`routeOverrides` applies `timeout`, `waitFor`, `readySelector`, `readyFlag`, `crawl` and `storageState` to matching routes; later entries win per key. `transformHtml` runs once per route after minification and before preload/CSP injection. It may be async and must return a string or nothing.
|
|
188
|
+
|
|
189
|
+
`preloadLinks` injects `<link rel="modulepreload">` for runtime chunks, font preloads with their response content type, and the LCP image. It complements `preloadManifest`: the manifest is for hosts that send Early Hints, while the injected links work on any static host. Script hints are skipped when `removeScriptTags` is on.
|
|
190
|
+
|
|
191
|
+
`csp: 'hash'` adds a `<meta http-equiv="Content-Security-Policy">` with SHA-256 hashes for inline scripts and styles. It implies `externalScripts: true` and no CSS swap handler, like `strict`. The policy allows `'self'` only, so third-party scripts or styles need their own policy; the audit warns when the browser reports a blocked request. An existing CSP meta is kept and reported. Inline `style=""` attributes and event handlers cannot be hashed; the audit warns about the attributes.
|
|
163
192
|
|
|
164
193
|
## Hydration verification
|
|
165
194
|
|
|
166
|
-
After writing the output,
|
|
195
|
+
After writing the output, each route is loaded again in a fresh browser context with the client bundle. By default the results are reported but do not fail the build; the static HTML is already written. Set `failOnHydrationError: true` (or pass `--fail-on-hydration-error`) to make hydration a build gate.
|
|
167
196
|
|
|
168
|
-
**Hydration errors.** React
|
|
197
|
+
**Hydration errors.** Mismatch messages for React, Vue, Svelte and Preact are reported with the route, framework and message. React text mismatches and minified production codes (`#418`, `#423`, `#425`) are recognised; Preact uses the React-compatible messages. A mismatch means the client re-renders the page instead of adopting the static markup. The crawler-visible HTML is unchanged.
|
|
169
198
|
|
|
170
|
-
|
|
199
|
+
The framework is detected from DOM markers only (`__reactContainer`, `__vue_app__`/`__vue__`, `__k`, `data-svelte-h`); nothing is imported or executed. Set `framework` when a custom root defeats detection. When a route has hydration errors or re-rendered, `firstMismatch` reports the first difference between the written HTML and the live container as `{ path, kind, expected, actual }`, bounded to 5,000 nodes and depth 20.
|
|
200
|
+
|
|
201
|
+
A probe installed before the app's scripts run records the first prerendered node and checks whether it survived:
|
|
171
202
|
|
|
172
203
|
| Mode | Meaning |
|
|
173
204
|
| --- | --- |
|
|
174
|
-
| `hydrated` | The app
|
|
205
|
+
| `hydrated` | The app kept the prerendered markup. |
|
|
175
206
|
| `re-rendered` | The app discarded it and rendered from scratch. |
|
|
176
|
-
| `undetected` | No
|
|
177
|
-
| `unknown` | The prerendered node was
|
|
207
|
+
| `undetected` | No framework root was found on the container. |
|
|
208
|
+
| `unknown` | The prerendered node was not seen, for example a container outside the usual ids. |
|
|
178
209
|
|
|
179
|
-
A
|
|
210
|
+
A verification navigation that returns HTTP 4xx/5xx, or a container with no content, is reported as failed with its `status` or `empty` flag. `undetected` and `unknown` are reported as counts; `failOnUndetected: true` fails the build for them. A verification pass that cannot run is listed in `verification.errors`; `failOnVerificationError: true` fails separately from hydration errors.
|
|
180
211
|
|
|
181
|
-
`re-rendered`
|
|
212
|
+
`re-rendered` usually means the app calls `createRoot` instead of `hydrateRoot`. Since `createRoot` does not emit a hydration error, the mode report is the only signal. It is reported per route as `verification.routes[].mode` and summarised in `verification.modes`. Set `failOnRerender: true` to fail the build.
|
|
182
213
|
|
|
183
|
-
**Page errors.**
|
|
214
|
+
**Page errors.** Uncaught browser errors are reported as warnings, and console errors at debug level. Errors thrown during rendering are counted in the summary and reported per route; `failOnPageError: true` makes them fail the build. By default the static HTML is still written.
|
|
184
215
|
|
|
185
|
-
**React 16 and 17.** Hydration and boot modes are judged the same way, and their dev mismatch warnings
|
|
216
|
+
**React 16 and 17.** Hydration and boot modes are judged the same way, and their dev mismatch warnings are recognised. Their production builds report nothing for a mismatch, so the boot mode (`hydrated` versus `re-rendered`) is the signal.
|
|
186
217
|
|
|
187
|
-
**Rebuilds.**
|
|
218
|
+
**Rebuilds.** `verifyChangedOnly: true` skips verification for routes whose HTML file did not change. The report shows how many routes were skipped.
|
|
188
219
|
|
|
189
220
|
## Ready contract
|
|
190
221
|
|
|
@@ -228,7 +259,7 @@ snappy({ inlineCss: true }) // alias for 'inline'
|
|
|
228
259
|
npm install --save-dev beasties
|
|
229
260
|
```
|
|
230
261
|
|
|
231
|
-
It inlines the critical CSS and converts the remaining stylesheets to non-blocking loads using `media="print"` plus an inline `onload` handler, with a `<noscript>` fallback.
|
|
262
|
+
It inlines the critical CSS and converts the remaining stylesheets to non-blocking loads using `media="print"` plus an inline `onload` handler, with a `<noscript>` fallback. The inline handler is inline JavaScript, so a strict `script-src` without `unsafe-inline` leaves the deferred stylesheets unapplied. Use `'inline'` or a nonce-aware setup in that case.
|
|
232
263
|
|
|
233
264
|
### Minification
|
|
234
265
|
|
|
@@ -236,7 +267,7 @@ It inlines the critical CSS and converts the remaining stylesheets to non-blocki
|
|
|
236
267
|
snappy({ minifyHtml: true, minifyCss: true });
|
|
237
268
|
```
|
|
238
269
|
|
|
239
|
-
`minifyHtml` uses html-minifier-terser with react-snap's defaults (whitespace collapsing, boolean attribute collapsing, attribute sorting). **Whitespace collapsing changes text nodes, which React
|
|
270
|
+
`minifyHtml` uses html-minifier-terser with react-snap's defaults (whitespace collapsing, boolean attribute collapsing, attribute sorting). **Whitespace collapsing changes text nodes, which React detects during hydration.** Use `{ collapseWhitespace: false }` if the verifier reports mismatches. `minifyCss` is passed to clean-css and also minifies CSS inlined into the HTML.
|
|
240
271
|
|
|
241
272
|
### Link hints
|
|
242
273
|
|
|
@@ -244,11 +275,11 @@ snappy({ minifyHtml: true, minifyCss: true });
|
|
|
244
275
|
snappy({ preconnectThirdParty: true, preloadImages: true, preloadManifest: true });
|
|
245
276
|
```
|
|
246
277
|
|
|
247
|
-
- `preconnectThirdParty` (default `true`) records every third-party origin the page tried to reach
|
|
278
|
+
- `preconnectThirdParty` (default `true`) records every third-party origin the page tried to reach, including blocked ones, and adds `<link rel="preconnect">` for each.
|
|
248
279
|
- `preloadImages` adds `<link rel="preload" as="image">` for same-origin images the page loaded.
|
|
249
|
-
- `preloadManifest` writes `preload-manifest.json
|
|
280
|
+
- `preloadManifest` writes `preload-manifest.json`: per route, a `Link` header value for the scripts and stylesheets the final HTML still references. Entries respect `ignoreForPreload` (default `['service-worker.js']`), inline CSS, tag removal and the base path. Serve them as Early Hints or `Link` headers.
|
|
250
281
|
|
|
251
|
-
react-snap called this `http2PushManifest`. Browsers removed HTTP/2 push (Chrome
|
|
282
|
+
react-snap called this `http2PushManifest`. Browsers removed HTTP/2 push (Chrome 106), so the manifest is a header list rather than a push list.
|
|
252
283
|
|
|
253
284
|
### Sitemap
|
|
254
285
|
|
|
@@ -256,7 +287,7 @@ react-snap called this `http2PushManifest`. Browsers removed HTTP/2 push (Chrome
|
|
|
256
287
|
snappy({ sitemap: true, metadata: { siteUrl: 'https://example.com' } });
|
|
257
288
|
```
|
|
258
289
|
|
|
259
|
-
|
|
290
|
+
The sitemap is generated from the written routes using the same page-path policy as canonical URLs. `noindex` pages and the not-found route are omitted. Above 50,000 URLs it is split behind a sitemap index. Entries have no `<lastmod>`; a build date would claim every page changed on every build.
|
|
260
291
|
|
|
261
292
|
When the output directory already has a `robots.txt`, a `Sitemap:` line is appended to it if it does not point anywhere yet; an existing directive is left alone. Without a `robots.txt`, the run logs the exact line to add instead of creating a file you did not ask for.
|
|
262
293
|
|
|
@@ -271,7 +302,7 @@ snappy({
|
|
|
271
302
|
});
|
|
272
303
|
```
|
|
273
304
|
|
|
274
|
-
The persisted metadata element is
|
|
305
|
+
The persisted metadata element is kept when `removeScriptTags` is on; other scripts are removed.
|
|
275
306
|
|
|
276
307
|
### Removing volatile markup
|
|
277
308
|
|
|
@@ -281,9 +312,9 @@ Mark any element with `data-prerender-remove` and it is dropped from the output:
|
|
|
281
312
|
<div data-prerender-remove>{ads.render()}</div>
|
|
282
313
|
```
|
|
283
314
|
|
|
284
|
-
Use it for regions that only
|
|
315
|
+
Use it for regions that only exist after the client takes over, such as ads or chat widgets. Remove markup that React does not render on its first client pass. Removing markup React expects causes the hydration mismatch the verifier reports.
|
|
285
316
|
|
|
286
|
-
Some libraries stamp values that change on every
|
|
317
|
+
Some libraries stamp values that change on every load. Ant Design's `rc-menu`, for example, writes `data-menu-id="rc-menu-uuid-…"`, which makes every rebuild rewrite every file and leaves `verifyChangedOnly` nothing to skip. List those attribute names (or RegExps) and they are removed from the output:
|
|
287
318
|
|
|
288
319
|
```js
|
|
289
320
|
snappy({ removeAttributes: ['data-menu-id', 'aria-controls'] });
|
|
@@ -314,21 +345,21 @@ Two things the dial cannot remove, because they are what prerendered HTML is:
|
|
|
314
345
|
|
|
315
346
|
## Third-party requests
|
|
316
347
|
|
|
317
|
-
Third-party requests are
|
|
348
|
+
Third-party requests are allowed by default. Most React sites load content from a CMS, headless API or separate service origin; blocking those during prerendering produces pages without data. The default matches react-snap.
|
|
318
349
|
|
|
319
350
|
```js
|
|
320
|
-
snappy({ blockThirdParty: false }); // default: allow
|
|
321
|
-
snappy({ blockThirdParty: true }); // abort
|
|
351
|
+
snappy({ blockThirdParty: false }); // default: allow all
|
|
352
|
+
snappy({ blockThirdParty: true }); // abort third-party requests
|
|
322
353
|
snappy({ blockThirdParty: true, allowedHosts: ['cms.example.com'] }); // block all but the CMS
|
|
323
354
|
```
|
|
324
355
|
|
|
325
|
-
|
|
356
|
+
Blocking makes rendering deterministic and keeps analytics, ads and chat widgets from executing during a build. `allowedHosts` keeps a CMS API reachable while blocking everything else.
|
|
326
357
|
|
|
327
|
-
Preconnect hints are generated for
|
|
358
|
+
Preconnect hints are generated for every third-party origin the page contacts, including allowlisted hosts while blocking. Set `preconnectThirdParty: false` to disable them. The CLI equivalent for blocking is `--block-third-party`.
|
|
328
359
|
|
|
329
360
|
## CSS-in-JS
|
|
330
361
|
|
|
331
|
-
Emotion, styled-components, vanilla-extract, stitches
|
|
362
|
+
Emotion, styled-components, vanilla-extract, stitches and JSS work when their styles end up as text inside a `<style>` tag. Three cases need extra handling:
|
|
332
363
|
|
|
333
364
|
**CSSOM-only styles.** In production, emotion and styled-components v5 switch to `CSSStyleSheet.insertRule` ("speedy" mode), which puts rules in the CSS object model and leaves the style element empty in the DOM. Serialising the page would drop every one of those rules. `captureRuntimeStyles` (default `true`) copies them back into the element text, and also folds document-level constructable stylesheets (`document.adoptedStyleSheets`) into a `<style>` tag. Set it to `false` to leave stylesheets untouched.
|
|
334
365
|
|
|
@@ -363,7 +394,7 @@ if (cached) return cached;
|
|
|
363
394
|
return fetch('/api/items?page=2').then((response) => response.json());
|
|
364
395
|
```
|
|
365
396
|
|
|
366
|
-
`window.snapStore` is keyed by the request path
|
|
397
|
+
`window.snapStore` is keyed by the request path, including its query string. Responses larger than `maxCachedBytes` (default 5 MiB) are skipped so one large endpoint cannot bloat every page.
|
|
367
398
|
|
|
368
399
|
**App state.** Define `window.snapSaveState` and whatever it returns is injected as globals before the first script:
|
|
369
400
|
|
|
@@ -438,7 +469,12 @@ The function is awaited once per run, and whatever it returns must be a plain op
|
|
|
438
469
|
| `exclude` | `[]` | Routes to skip, strings or RegExp |
|
|
439
470
|
| `crawl` | `true` | Follow same-origin links from seeds |
|
|
440
471
|
| `maxDepth` | `null` | Crawl depth limit, `null` is unlimited, `0` renders seeds only |
|
|
441
|
-
| `maxRoutes` | `null` | Stop after this many routes; hitting the cap marks the run incomplete |
|
|
472
|
+
| `maxRoutes` | `null` | Stop after this many routes; hitting the cap marks the run incomplete and lists the routes that did not fit in `truncated.droppedRoutes` |
|
|
473
|
+
| `routePriority` | `[]` | Patterns ranked first when crawling, strings or RegExp; setting it selects deterministic BFS |
|
|
474
|
+
| `routesFile` | `null` | Text or JSON route seeds, one route per line or `{ "routes": [] }`; a relative path resolves against the config file |
|
|
475
|
+
| `routesFromSitemap` | `null` | Local path or http(s) URL whose `<loc>` entries seed routes; sitemap indexes are followed one level, the public base is stripped from root-relative locs, and off-origin locs are ignored. Absolute locs in a local sitemap need `metadata.siteUrl` or a remote sitemap origin |
|
|
476
|
+
| `routeOverrides` | `[]` | Per-route `{ match, timeout, waitFor, readySelector, readyFlag, crawl, storageState }`; later entries win |
|
|
477
|
+
| `transformHtml` | `null` | Function `(html, { route, file, stats, config })` run before preload/CSP injection; may be async |
|
|
442
478
|
| `concurrency` | derived | Parallel pages, derived from CPU count, capped at 8 |
|
|
443
479
|
| `timeout` | `30000` | Navigation, ready and network-settle timeout in ms; each wait gets this budget |
|
|
444
480
|
| `quietPeriod` | `500` | Network must be idle this long before capture |
|
|
@@ -462,7 +498,7 @@ The function is awaited once per run, and whatever it returns must be a plain op
|
|
|
462
498
|
| `scrollStepDelay` | `100` | Delay between scroll steps when `scrollToBottom` is on |
|
|
463
499
|
| `captureRuntimeStyles` | `true` | Fold CSSOM-only styles and constructable stylesheets into the output |
|
|
464
500
|
| `captureFormState` | `true` | Sync `checked` and `selected` into the output markup |
|
|
465
|
-
| `csp` | `'off'` | `'off'` leaves the injected pieces inline; `'strict'` makes the output work under `script-src 'self'` by moving state to a same-origin file and dropping the CSS swap handlers |
|
|
501
|
+
| `csp` | `'off'` | `'off'` leaves the injected pieces inline; `'strict'` makes the output work under `script-src 'self'` by moving state to a same-origin file and dropping the CSS swap handlers; `'hash'` adds a meta policy with SHA-256 hashes for inline scripts and styles |
|
|
466
502
|
| `inlineCss` | `false` | `'inline'`, `'critical'` (needs beasties) or `true` for `'inline'` |
|
|
467
503
|
| `criticalCssPreload` | `'media'` | Swap used for CSS deferred by `inlineCss: 'critical'`; `false` emits no swap handlers, for a strict script-src |
|
|
468
504
|
| `minifyHtml` | `false` | Minify output HTML, `true` for defaults or an html-minifier-terser options object |
|
|
@@ -470,8 +506,10 @@ The function is awaited once per run, and whatever it returns must be a plain op
|
|
|
470
506
|
| `preconnectThirdParty` | `true` | Add preconnect hints for every third-party origin the page contacts |
|
|
471
507
|
| `preloadImages` | `false` | Add preload hints for same-origin images |
|
|
472
508
|
| `preloadManifest` | `false` | Write `preload-manifest.json` with Link header hints, derived from the final HTML |
|
|
473
|
-
| `
|
|
509
|
+
| `preloadLinks` | `false` | Inject module, font and LCP image preload hints for static hosts; script hints are skipped when `removeScriptTags` is on |
|
|
510
|
+
| `ignoreForPreload` | `['service-worker.js']` | File names excluded from the manifest and injected hints |
|
|
474
511
|
| `sitemap` | `false` | Write `sitemap.xml` (or a sitemap index above 50,000 URLs) from the routes that do not declare noindex, and point an existing `robots.txt` at it; needs `metadata.siteUrl` |
|
|
512
|
+
| `imageSitemap` | `false` | List same-origin page images in the sitemap |
|
|
475
513
|
| `cacheAjaxRequests` | `false` | Expose captured JSON responses as `window.snapStore` |
|
|
476
514
|
| `maxCachedBytes` | `5242880` | Largest JSON response cached per request, measured on the serialised body |
|
|
477
515
|
| `removeBlobs` | `true` | Drop stylesheet links pointing at dead `blob:` URLs |
|
|
@@ -482,12 +520,20 @@ The function is awaited once per run, and whatever it returns must be a plain op
|
|
|
482
520
|
| `removeStyleTags` | `false` | Strip every style tag from the output; cannot be combined with `inlineCss` `'inline'` |
|
|
483
521
|
| `removeScriptTags` | `false` | Strip every script tag from the output |
|
|
484
522
|
| `asyncScriptTags` | `false` | Mark external scripts async |
|
|
485
|
-
| `externalScripts` | `false` | Write injected state scripts as content-hashed same-origin files instead of inline; set by `csp: 'strict'` |
|
|
523
|
+
| `externalScripts` | `false` | Write injected state scripts as content-hashed same-origin files instead of inline; set by `csp: 'strict'` or `'hash'` |
|
|
486
524
|
| `flatOutput` | `false` | Write `about.html` instead of `about/index.html` |
|
|
487
|
-
| `notFoundRoute` | `/404` | Route emitted as `404.html` with a robots noindex tag; a notice is logged when it is never prerendered |
|
|
525
|
+
| `notFoundRoute` | `/404` | Route emitted as `404.html` with a robots noindex tag, even when the server answers HTTP 404; a notice is logged when it is never prerendered. A page can also declare `<meta name="prerender-status-code" content="404">` |
|
|
526
|
+
| `audit` | `true` | Check the written site for route health, broken links, metadata, sitemap and CSP issues |
|
|
527
|
+
| `failOnAuditError` | `false` | Fail when the audit finds an error |
|
|
528
|
+
| `auditIgnoreLinks` | `[]` | Link patterns excluded from the audit, strings or RegExp |
|
|
529
|
+
| `reportPath` | `null` | Write the versioned JSON run report to this file; URLs and the storage-state path are redacted |
|
|
488
530
|
| `saveAs` | `html` | `html`, `png` or `jpeg`; identical screenshots are left untouched |
|
|
489
531
|
| `metadata` | `null` | Defaults for the head component: `siteUrl` (origin only), `siteName`, `titleTemplate`, `defaultImage`, `trailingSlash`, `base` |
|
|
490
532
|
| `verify` | `true` | Run the hydration verification pass |
|
|
533
|
+
| `framework` | `auto` | `auto`, `react`, `vue`, `svelte` or `preact`; detects the mounted framework from DOM markers |
|
|
534
|
+
| `retries` | `0` | Retry a retryable render failure this many times |
|
|
535
|
+
| `retryDelay` | `500` | Wait between render attempts, in ms |
|
|
536
|
+
| `traceOnError` | `false` | Write a Playwright trace for the final failed attempt under `snappy-traces/` |
|
|
491
537
|
| `verifyChangedOnly` | `false` | Skip verification for routes whose HTML file did not change since the last run |
|
|
492
538
|
| `failOnHydrationError` | `false` | Fail the run on hydration errors; off by default, where they are reported instead |
|
|
493
539
|
| `failOnRerender` | `false` | Fail the run when a route re-renders instead of hydrating |
|
|
@@ -522,38 +568,13 @@ if (!report.ok) {
|
|
|
522
568
|
}
|
|
523
569
|
```
|
|
524
570
|
|
|
525
|
-
The report exposes `routes`, `files` (with per-route `status` and `noindex`), `errors`, `pageErrors` (uncaught browser errors seen while rendering), `consoleErrors`, `failedRequests`, `emptyPages`, `duplicatePages`, `duplicateTitles` (routes shipping more than one title), `verification` (nullable; per-route `mode`, `status` and `empty` plus
|
|
571
|
+
The report exposes `routes`, `files` (with per-route `status` and `noindex`), `routeDetails` (the per-route records used by the JSON report), `errors`, `pageErrors` (uncaught browser errors seen while rendering), `consoleErrors`, `failedRequests`, `emptyPages`, `duplicatePages`, `duplicateTitles` (routes shipping more than one title), `verification` (nullable; per-route `mode`, `framework`, `firstMismatch`, `status` and `empty` plus `modes` and `frameworks` summaries), `audit` (nullable; `errors`, `warnings`, `linksChecked`), `preloadManifest`, `sitemap`, `pruned`, `truncated`, `notFoundRoutes`, `cspSkipped`, `traces`, and `ok`. See [docs/report.md](docs/report.md) for the JSON schema.
|
|
526
572
|
|
|
527
573
|
`snappy-prerender` exports `DEFAULTS`, `prerender` and `resolveConfig`; the default export is the Vite plugin.
|
|
528
574
|
|
|
529
|
-
##
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
Changed: `http2PushManifest` became `preloadManifest` (browsers removed HTTP/2 push), `fixInsertRule` became `captureRuntimeStyles` and also covers constructable stylesheets, `fixFormFields` became `captureFormState`, `puppeteerArgs` became `browserArgs`, `puppeteerIgnoreHTTPSErrors` became `ignoreHTTPSErrors`, `skipThirdPartyRequests` became `blockThirdParty` with the same default of allowing them, `exclude` and `maxRoutes` are new, and `notFoundRoute` replaces the `/404` include convention.
|
|
534
|
-
|
|
535
|
-
Dropped: `sourceMaps` (declared but never referenced in react-snap's code), `fixWebpackChunksIssue` and `fixInsertRule` (webpack/Chrome-era workarounds), `port` (ephemeral loopback port instead), `puppeteer.cache`, and the preload polyfill (modulepreload is universally supported).
|
|
536
|
-
|
|
537
|
-
## Limitations
|
|
538
|
-
|
|
539
|
-
- **Build-time data is a snapshot.** Anything fetched during rendering is frozen into the HTML until the next build. Use `cacheAjaxRequests` and `snapSaveState` so the client replays the same data.
|
|
540
|
-
- **Hydration mismatches are your app's to fix.** The verifier tells you exactly which route and which React error. Common causes: `Date.now()`, `Math.random()`, `localStorage` reads during render, viewport-dependent markup, and CSS-in-JS that re-injects styles on hydration.
|
|
541
|
-
- **Markup that depends on load state cannot hydrate.** A component that swaps a placeholder for real content once an image or widget loads renders one thing during prerendering (where the network has settled) and another on the client's first render. The verifier reports those routes as `re-rendered`. Render deterministic markup instead — a plain `<img loading="lazy">` rather than a JS placeholder swap — or accept the re-render.
|
|
542
|
-
- **Authenticated routes need `storageState`.** Never prerender personal data into static HTML without deciding to.
|
|
543
|
-
- **Runtime-only routes** (heavy API dependence, real-time data) are better served by `serveCmd` or left client-rendered.
|
|
544
|
-
- Route query strings are ignored; routes are deduplicated without them.
|
|
545
|
-
- Routes whose decoded path contains dot segments or backslashes are skipped, so encoded traversal cannot create stray directories.
|
|
546
|
-
- Crawling is unbounded unless `maxRoutes` is set; hitting the cap marks the run as failed so incomplete output is never shipped silently. Which routes are cut is concurrency-dependent on a large site — narrow `include`/`exclude` instead when you need a deterministic set.
|
|
547
|
-
- **React 19 native metadata.** React hoists `<title>` and `<meta>` rendered in JSX and leaves an existing template title in place, so using both systems produces two titles in the output. Use one of them; the run warns when a page ships more than one `<title>`.
|
|
548
|
-
- If two routes would write the same file — such as `/` and `/index` with `flatOutput` — neither is written and the run fails with a collision error.
|
|
549
|
-
- Screenshots are viewport-width full-page captures, so they reflect the configured `viewport`, not a device matrix. Identical screenshots are left untouched.
|
|
550
|
-
- **Output files from routes that no longer exist** are left in place unless `pruneStaleRoutes` is enabled, which deletes only files listed in the previous run's `.snappy-manifest.json`.
|
|
551
|
-
- **Dead extensionless links** are indistinguishable from SPA routes to the static server, so a missing page can render the shell or the app's catch-all 404. Duplicate output is reported; set `failOnDuplicateContent` to enforce it, and use an app-level 404 marker where possible.
|
|
552
|
-
- **Metadata pointing at the build server** is removed by default (`stripBuildOriginMetadata: true`) and reported. Set `metadata.siteUrl` so canonical and social URLs survive.
|
|
553
|
-
- **`inlineCss`** rebases relative font and image URLs against each stylesheet. A sheet that uses `@import` is left as a link because concatenating it would change the cascade.
|
|
554
|
-
- **`verifyChangedOnly` compares the generated HTML only.** If a bundle keeps the same filename while its contents change, that route's HTML is unchanged and its verification is skipped; content-hashed asset names (Vite and CRA defaults) make the HTML change as well.
|
|
555
|
-
- **Destination directories are merged unless `cleanDestination` is on.** That option empties the destination first; `pruneStaleRoutes` separately removes pages the run itself generated.
|
|
556
|
-
- **`removeStyleTags`** cannot be combined with `inlineCss: 'inline'` or `true`; the config is rejected instead of silently shipping pages without CSS.
|
|
575
|
+
## Further reading
|
|
576
|
+
|
|
577
|
+
[Limitations](docs/limitations.md), [report schema and audit rules](docs/report.md), [migrating from react-snap](docs/react-snap-migration.md).
|
|
557
578
|
|
|
558
579
|
## Requirements
|
|
559
580
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Limitations
|
|
2
|
+
|
|
3
|
+
- **Build-time data is a snapshot.** Anything fetched during rendering is frozen into the
|
|
4
|
+
HTML until the next build. Use `cacheAjaxRequests` and `snapSaveState` so the client
|
|
5
|
+
replays the same data.
|
|
6
|
+
- **Hydration mismatches are your app's to fix.** The verifier tells you exactly which route
|
|
7
|
+
and which framework error. Common causes: `Date.now()`, `Math.random()`, `localStorage`
|
|
8
|
+
reads during render, viewport-dependent markup, and CSS-in-JS that re-injects styles on
|
|
9
|
+
hydration.
|
|
10
|
+
- **Markup that depends on load state cannot hydrate.** A component that swaps a placeholder
|
|
11
|
+
for real content once an image or widget loads renders one thing during prerendering
|
|
12
|
+
(where the network has settled) and another on the client's first render. The verifier
|
|
13
|
+
reports those routes as `re-rendered`. Render deterministic markup instead — a plain
|
|
14
|
+
`<img loading="lazy">` rather than a JS placeholder swap — or accept the re-render.
|
|
15
|
+
- **Authenticated routes need `storageState`.** Never prerender personal data into static
|
|
16
|
+
HTML without deciding to.
|
|
17
|
+
- **Runtime-only routes** (heavy API dependence, real-time data) are better served by
|
|
18
|
+
`serveCmd` or left client-rendered.
|
|
19
|
+
- Route query strings are ignored; routes are deduplicated without them.
|
|
20
|
+
- Routes whose decoded path contains dot segments or backslashes are skipped, so encoded
|
|
21
|
+
traversal cannot create stray directories.
|
|
22
|
+
- Crawling is unbounded unless `maxRoutes` is set; hitting the cap marks the run as failed
|
|
23
|
+
so incomplete output is never shipped silently. With `maxRoutes` or `routePriority`, the
|
|
24
|
+
crawl runs in deterministic waves and reports exactly which routes did not fit in
|
|
25
|
+
`truncated.droppedRoutes`.
|
|
26
|
+
- **React 19 native metadata.** React hoists `<title>` and `<meta>` rendered in JSX and
|
|
27
|
+
leaves an existing template title in place, so using both systems produces two titles in
|
|
28
|
+
the output. Use one of them; the run warns when a page ships more than one `<title>`.
|
|
29
|
+
- If two routes would write the same file — such as `/` and `/index` with `flatOutput` —
|
|
30
|
+
neither is written and the run fails with a collision error.
|
|
31
|
+
- Screenshots are viewport-width full-page captures, so they reflect the configured
|
|
32
|
+
`viewport`, not a device matrix. Identical screenshots are left untouched.
|
|
33
|
+
- **Output files from routes that no longer exist** are left in place unless
|
|
34
|
+
`pruneStaleRoutes` is enabled, which deletes only files listed in the previous run's
|
|
35
|
+
`.snappy-manifest.json`.
|
|
36
|
+
- **Dead extensionless links** are indistinguishable from SPA routes to the static server,
|
|
37
|
+
so a missing page can render the shell or the app's catch-all 404. Duplicate output is
|
|
38
|
+
reported; set `failOnDuplicateContent` to enforce it, and use an app-level 404 marker
|
|
39
|
+
where possible.
|
|
40
|
+
- **Metadata pointing at the build server** is removed by default
|
|
41
|
+
(`stripBuildOriginMetadata: true`) and reported. Set `metadata.siteUrl` so canonical and
|
|
42
|
+
social URLs survive.
|
|
43
|
+
- **`inlineCss`** rebases relative font and image URLs against each stylesheet. A sheet that
|
|
44
|
+
uses `@import` is left as a link because concatenating it would change the cascade.
|
|
45
|
+
- **`verifyChangedOnly` compares the generated HTML only.** If a bundle keeps the same
|
|
46
|
+
filename while its contents change, that route's HTML is unchanged and its verification
|
|
47
|
+
is skipped; content-hashed asset names (Vite and CRA defaults) make the HTML change as
|
|
48
|
+
well.
|
|
49
|
+
- **Destination directories are merged unless `cleanDestination` is on.** That option
|
|
50
|
+
empties the destination first; `pruneStaleRoutes` separately removes pages the run itself
|
|
51
|
+
generated.
|
|
52
|
+
- **`removeStyleTags`** cannot be combined with `inlineCss: 'inline'` or `true`; the config
|
|
53
|
+
is rejected instead of silently shipping pages without CSS.
|
|
54
|
+
- **CSP `hash` mode cannot cover inline event handlers or `style=""` attributes.** Move
|
|
55
|
+
those styles into a `<style>` element or a stylesheet; the audit warns when attributes are
|
|
56
|
+
present.
|
|
57
|
+
- **Failure traces can contain request data.** `traceOnError` is opt-in and writes a
|
|
58
|
+
Playwright archive under `snappy-traces/` in the output directory.
|