Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate a list of assets to cache for offline support (#1573)
## Motivation for the change, related issues To make [Playground available offline ](#1535 will need to precache all Playground assets. This PR generates a list of all assets Playground needs to run offline. #1535 will use the asset file. ## Implementation details The PR implements a new Vite plugin (`websiteCachePathsPlugin`). The plugin runs every time the website is built and scans through the `website`, `remote`, and `client` dist folders for cache files. We need to do this because Vite generates new file names on each build. For example `index.js` will be `index-HASH.js`. To detect all required files, the plugin has a list of regex expressions that will match these files no matter what hash Vite generates. ## Testing Instructions (or ideally a Blueprint) - Run `npm run build:website` - Confirm that `dist/packages/playground/wasm-wordpress-net/cache-files.json` exists - The file should look similar to this ``` [ "/assets/brain-1418d665.svg", "/assets/builder/builder.html-f350f1dc.js", "/assets/builder-0648a1dd.css", "/assets/client-102d8634.js", "/assets/config-2a6ab1ba.js", "/assets/download-d32bab19.svg", "/assets/edit-79dd2f3b.svg", "/assets/index-2a538d29.js", "/assets/index-d60708af.css", "/assets/main-7bf730a2.css", "/assets/main-88eaa39a.js", "/assets/modulepreload-polyfill-3cfb730f.js", "/assets/new-tab-button-f20e269a.svg", "/assets/open-11ad4fc6.svg", "/assets/peer-dbe7a0a3.js", "/assets/peer.html-34c24b0c.js", "/assets/php-blueprints-60a056f1.js", "/assets/php-blueprints.html-6ff813c0.js", "/assets/play-button-d16471c4.svg", "/assets/preload-helper-cf010ec4.js", "/assets/save-f248e35e.svg", "/assets/setup-playground-sync-f9eff12c.js", "/assets/sync.html-5a4cfeb8.js", "/assets/terminal-249bb152.css", "/assets/terminal-3554f247.js", "/assets/time-traveling-2c4678ce.js", "/assets/time-traveling.html-14ccf92b.js", "/assets/wp-cli.html-55f77252.js", "/assets/x-90ad5814.svg", "/assets/zoom-in-b8a0c399.svg", "/assets/zoom-out-7892b279.svg", "/builder/builder.html", "/favicon.ico", "/gutenberg.css", "/gutenberg.html", "/index.html", "/logo-192.png", "/logo-256.png", "/logo-384.png", "/logo-512.png", "/manifest.json", "/ogimage.png", "/previewer.css", "/wordpress-importer.zip", "/wordpress.html", "/wordpress.svg", "/assets/remote-b5d5f2da.css", "/assets/wordpress-e45f8a8e.js", "/remote.html", "/sw.js", "/worker-thread-aa53dc45.js", "/index.js" ] ``` --------- Co-authored-by: Adam Zieliński <[email protected]>
- Loading branch information