Skip to content
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

Generate a list of assets to cache for offline support #1573

Merged
merged 53 commits into from
Jul 15, 2024

Conversation

bgrgicak
Copy link
Collaborator

@bgrgicak bgrgicak commented Jul 4, 2024

Motivation for the change, related issues

To make Playground available offline we 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"
]

@bgrgicak bgrgicak self-assigned this Jul 4, 2024
/**
* Files needed only by the Playground.WordPress.Net server.
*/
'/.htaccess',
Copy link
Collaborator

Choose a reason for hiding this comment

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

@brandonpayton Are we good to remove the .htaccess file now that Playground runs on the Atomic platform?

@bgrgicak bgrgicak requested a review from adamziel July 15, 2024 08:34
@bgrgicak bgrgicak requested a review from adamziel July 15, 2024 11:51
Copy link
Collaborator

@adamziel adamziel left a comment

Choose a reason for hiding this comment

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

All my notes are related to code style and comments, the essence of this PR is spot on. Thank you @bgrgicak!

@bgrgicak
Copy link
Collaborator Author

I addressed everything, should be ready to merge now.

@bgrgicak bgrgicak merged commit a740f6f into trunk Jul 15, 2024
5 checks passed
@bgrgicak bgrgicak deleted the add/vite-cache-paths-plugin branch July 15, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants