Skip to content

Commit

Permalink
Ignore consent for main script
Browse files Browse the repository at this point in the history
  • Loading branch information
haslo committed Oct 8, 2024
1 parent 1a91f30 commit 91edae2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/>
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
<script type="module" src="/src/index.jsx"></script>
<script type="module" data-cookieconsent="ignore" src="/src/index.jsx"></script>
<title>haslo.ch - Techno and Plugins from Bern, Switzerland</title>
</head>
<body>
Expand Down
32 changes: 28 additions & 4 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

// Custom plugin to add data-cookieconsent="ignore" to the main script
const addCookieConsentIgnore = () => {
return {
name: 'add-cookie-consent-ignore',
transformIndexHtml(html) {
return html.replace(
/<script type="module" crossorigin/,
'<script type="module" crossorigin data-cookieconsent="ignore"'
)
}
}
}

export default defineConfig({
plugins: [react()],
plugins: [
react(),
addCookieConsentIgnore()
],
server: {
open: true,
},
});
build: {
rollupOptions: {
input: {
main: path.resolve(__dirname, 'index.html'),
},
},
},
})

0 comments on commit 91edae2

Please sign in to comment.