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 {
|
return {
|
||||||
name: PACKAGE_NAME,
|
name: PACKAGE_NAME,
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:setup': ({ config, updateConfig, injectScript }) => {
|
'astro:config:setup': ({ command, config, updateConfig, injectScript }) => {
|
||||||
if (analytics) {
|
if (command === 'build' && analytics) {
|
||||||
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
||||||
}
|
}
|
||||||
const outDir = getVercelOutput(config.root);
|
const outDir = getVercelOutput(config.root);
|
||||||
|
|
|
@ -35,8 +35,8 @@ export default function vercelServerless({
|
||||||
return {
|
return {
|
||||||
name: PACKAGE_NAME,
|
name: PACKAGE_NAME,
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:setup': ({ config, updateConfig, injectScript }) => {
|
'astro:config:setup': ({ command, config, updateConfig, injectScript }) => {
|
||||||
if (analytics) {
|
if (command === 'build' && analytics) {
|
||||||
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
||||||
}
|
}
|
||||||
const outDir = getVercelOutput(config.root);
|
const outDir = getVercelOutput(config.root);
|
||||||
|
|
|
@ -19,8 +19,8 @@ export default function vercelStatic({ analytics }: VercelStaticConfig = {}): As
|
||||||
return {
|
return {
|
||||||
name: '@astrojs/vercel',
|
name: '@astrojs/vercel',
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:setup': ({ config, injectScript }) => {
|
'astro:config:setup': ({ command, config, injectScript }) => {
|
||||||
if (analytics) {
|
if (command === 'build' && analytics) {
|
||||||
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
||||||
}
|
}
|
||||||
config.outDir = new URL('./static/', getVercelOutput(config.root));
|
config.outDir = new URL('./static/', getVercelOutput(config.root));
|
||||||
|
|
Loading…
Reference in a new issue