Skip to content

Commit

Permalink
feat: conditionally output analysis JS only in Vercel environment (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liudon authored Sep 25, 2024
1 parent 371ce67 commit d58493b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const Index = () => {
)}
</div>
{/* Enable Audiences in Vercel Analytics: https://vercel.com/docs/concepts/analytics/audiences/quickstart */}
<Analytics />
{import.meta.env.VERCEL && <Analytics /> }
</Layout>
);
};
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export default defineConfig({
}),
],
base: process.env.PATH_PREFIX || '/',
define: {
"import.meta.env.VERCEL": JSON.stringify(process.env.VERCEL),
},
build: {
manifest: true,
outDir: './dist', // for user easy to use, vercel use default dir -> dist
Expand Down

0 comments on commit d58493b

Please sign in to comment.