Skip to content

Commit

Permalink
port vite-plugin-html-prerender
Browse files Browse the repository at this point in the history
  • Loading branch information
Asvarox committed Jul 1, 2024
1 parent 62ffc3b commit 99fb2ac
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 43 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-no-only-tests": "^3.1.0",
"express": "^4.19.2",
"happy-dom": "^12.10.3",
"html-minifier": "^4.0.0",
"husky": "^9.0.11",
"js-yaml": "^4.1.0",
"lint-staged": "^15.2.2",
Expand All @@ -144,7 +146,7 @@
"playwright-core": "^1.43.1",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"puppeteer": "^21.6.1",
"puppeteer": "^21.11.0",
"react-refresh": "^0.14.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-visualizer": "^5.12.0",
Expand All @@ -155,7 +157,6 @@
"unimported": "^1.30.0",
"utility-types": "^3.11.0",
"vite": "^5.2.9",
"vite-plugin-html-prerender": "https://github.com/Asvarox/vite-plugin-html-prerender#dist",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.4.0"
},
Expand Down
73 changes: 33 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vite-plugin-html-prerender/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Saeed Afzal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 48 additions & 0 deletions vite-plugin-html-prerender/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# vite-plugin-html-prerender

Vite.js plugin for pre-rendering html for SPAs.

## Install
```shell
npm i -D vite-plugin-html-prerender
```

## Usage
Add `htmlPrerender` to your configuration (`vite.config.js`/`vite.config.ts`):
```typescript
import { defineConfig } from "vite";
import { htmlPrerender } from "vite-plugin-html-prerender";
import path from "path";

export default defineConfig({
plugins: [
htmlPrerender({
/**
* Required: Output directory of `vite build`.
*/
staticDir: path.join(__dirname, "dist"),

/**
* Required: List of routes to pre-render.
*/
routes: ["/", "/about"],

/**
* Optional: Query selector to wait for. Defaults to `#root`.
*/
selector: "main",

/**
* Optional: To minify html. Uses https://github.com/kangax/html-minifier.
*/
minify: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
keepClosingSlash: true,
sortAttributes: true
}
})
]
});
```
3 changes: 3 additions & 0 deletions vite-plugin-html-prerender/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import htmlPrerender from './prerender';

export { htmlPrerender };
Loading

0 comments on commit 99fb2ac

Please sign in to comment.