Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<!-- Statcounter placeholder -->
</body>
</html>
19 changes: 19 additions & 0 deletions src/utils/statcounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Statcounter HTML template for production builds
* https://statcounter.com
*/
export const statcounterHtml = `<!-- Default Statcounter code for CinéPleinAir https://cinepleinair.org -->
<script type="text/javascript">
var sc_project=13335582;
var sc_invisible=1;
var sc_security="a80fbc83";
</script>
<script type="text/javascript" src="https://www.statcounter.com/counter/counter.js" async></script>
<noscript>
<div class="statcounter">
<a title="Web Analytics" href="https://statcounter.com/" target="_blank">
<img class="statcounter" src="https://c.statcounter.com/13335582/0/a80fbc83/1/" alt="Web Analytics" referrerPolicy="no-referrer-when-downgrade">
</a>
</div>
</noscript>
<!-- End of Statcounter Code -->`
14 changes: 14 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'
import path from 'path'
import constants from './src/constants.js'
import { statcounterHtml } from './src/utils/statcounter.js'

export default defineConfig({
plugins: [
vue(),
{
name: 'statcounter',
transformIndexHtml(html) {
// Only inject Statcounter in production
if (process.env.NODE_ENV === 'production') {
return html.replace(
'<!-- Statcounter placeholder -->',
statcounterHtml
)
}
return html
}
},
VitePWA({
registerType: 'prompt',
includeAssets: ['favicon.ico', 'favicon.png'],
Expand Down