Only inject Vercel analytics in production (#6258)
* Only inject Vercel analytics in production * Add changeset
This commit is contained in:
parent
241c178354
commit
0fe74b6648
4 changed files with 11 additions and 6 deletions
5
.changeset/dull-wasps-decide.md
Normal file
5
.changeset/dull-wasps-decide.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/vercel': patch
|
||||
---
|
||||
|
||||
Don’t inject analytics script in dev
|
|
@ -40,8 +40,8 @@ export default function vercelEdge({
|
|||
return {
|
||||
name: PACKAGE_NAME,
|
||||
hooks: {
|
||||
'astro:config:setup': ({ config, updateConfig, injectScript }) => {
|
||||
if (analytics) {
|
||||
'astro:config:setup': ({ command, config, updateConfig, injectScript }) => {
|
||||
if (command === 'build' && analytics) {
|
||||
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
||||
}
|
||||
const outDir = getVercelOutput(config.root);
|
||||
|
|
|
@ -35,8 +35,8 @@ export default function vercelServerless({
|
|||
return {
|
||||
name: PACKAGE_NAME,
|
||||
hooks: {
|
||||
'astro:config:setup': ({ config, updateConfig, injectScript }) => {
|
||||
if (analytics) {
|
||||
'astro:config:setup': ({ command, config, updateConfig, injectScript }) => {
|
||||
if (command === 'build' && analytics) {
|
||||
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
||||
}
|
||||
const outDir = getVercelOutput(config.root);
|
||||
|
|
|
@ -19,8 +19,8 @@ export default function vercelStatic({ analytics }: VercelStaticConfig = {}): As
|
|||
return {
|
||||
name: '@astrojs/vercel',
|
||||
hooks: {
|
||||
'astro:config:setup': ({ config, injectScript }) => {
|
||||
if (analytics) {
|
||||
'astro:config:setup': ({ command, config, injectScript }) => {
|
||||
if (command === 'build' && analytics) {
|
||||
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
||||
}
|
||||
config.outDir = new URL('./static/', getVercelOutput(config.root));
|
||||
|
|
Loading…
Reference in a new issue