-
There are already example how to add scripts, such as Google Analytics or Umami, to the head section. However, when I develop, it also track my views and interactions. How can I only load the analytics script only in production build, and not in development or test? There is no NODE_ENV that I can use |
Beta Was this translation helpful? Give feedback.
Answered by
khanetor
Jun 13, 2024
Replies: 1 comment 5 replies
-
Have you tried it? It's there. import { defineConfig } from 'vitepress'
const inProd = process.env.NODE_ENV === 'production'
export default defineConfig({
head: [
inProd && ['script', { src: '...' }],
[...]
].filter(Boolean)
}) |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I finally settled on this approach
And then set this to the head in config.