Skip to content

Commit

Permalink
playground
Browse files Browse the repository at this point in the history
  • Loading branch information
wille committed Aug 18, 2024
1 parent cce0c80 commit f2e3ce2
Show file tree
Hide file tree
Showing 19 changed files with 3,306 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
Expand All @@ -14,6 +15,7 @@ jobs:
node-version: "22.5"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run build
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# vite-preload

This plugin will significantly speed up your server rendered vite application by preloading async modules as early as possible and avoid Flash Of Unstyled Content (FOUC) by including stylesheets from async modules in the initial HTML.
This plugin will significantly speed up your server rendered vite application by preloading async modules as early as possible and it will avoid Flash Of Unstyled Content (FOUC) by including stylesheets from async modules in the initial HTML.

## Explainer

Vite supports `React.lazy()` just fine but any lazy imported modules and its CSS imports will not be injected into html or DOM until the entrypoint module has imported them.

It's a common pattern to have each page/route in your application lazy loaded especially if you are migrating to Vite from something else like webpack with loadable-components.

This is a plugin that will collect what modules are rendered on the server and help you inject `<link>` tags and `Link` preload headers for early hints.
This plugin will collect which modules are rendered on the server and help you inject `<link>` tags and `Link` preload headers for early hints.

Read more: [Backend Integration](https://vitejs.dev/guide/backend-integration.html) [Server Side Rendering](https://vitejs.dev/guide/ssr.html)
Read more:
- [Backend Integration](https://vitejs.dev/guide/backend-integration.html)
- [Server Side Rendering](https://vitejs.dev/guide/ssr.html)

## Without preloading

Expand Down
14 changes: 14 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<!--app-head-->
</head>
<body>
<div id="root"><!--app-html--></div>
<script type="module" src="/src/entry-client.tsx"></script>
</body>
</html>
Loading

0 comments on commit f2e3ce2

Please sign in to comment.