Skip to content

Commit 23dc3b2

Browse files
committed
Add vite plugin to inject custom tags into index.html
1 parent 0c9b3a8 commit 23dc3b2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.github/workflows/jekyll-gh-pages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
run: npm run build
4242
env:
4343
VITE_SUPPORT_EMAIL: ${{ secrets.SUPPORT_EMAIL }}
44+
VITE_CUSTOM_HTML_TAGS: ${{ secrets.CUSTOM_HTML_TAGS }}
4445
- name: Setup Pages
4546
uses: actions/configure-pages@v5
4647
- name: Upload artifact

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<title>GaliGuessr - Quiz de xeografía de Galicia</title>
1919
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2020
<meta name="description" content="Quiz de xeografía de Galicia">
21+
<!-- INJECT_CUSTOM_TAGS -->
2122
</head>
2223

2324
<body>

vite.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ export default defineConfig(({ mode }) => {
1414
const env = loadEnv(mode, process.cwd(), "VITE_");
1515

1616
return {
17-
plugins: [react()],
17+
plugins: [
18+
react(),
19+
{
20+
name: "custom-html-tags-injector",
21+
transformIndexHtml(html) {
22+
const tags = env.VITE_CUSTOM_HTML_TAGS || "";
23+
return html.replace("<!-- INJECT_CUSTOM_TAGS -->", tags);
24+
}
25+
}
26+
],
1827
base: "/galiguessr/",
1928
define: {
2029
"process.env": {

0 commit comments

Comments
 (0)