Fix external dependency issue
This commit is contained in:
parent
ad86e9f648
commit
e492e948df
3 changed files with 20 additions and 2 deletions
|
@ -9,6 +9,20 @@ export type VercelWebAnalyticsConfig = {
|
||||||
config?: Omit<AnalyticsProps, 'beforeSend'>;
|
config?: Omit<AnalyticsProps, 'beforeSend'>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getWebAnalyticsViteConfig(enabled?: boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
return {
|
||||||
|
build: {
|
||||||
|
rollupOptions: {
|
||||||
|
external: ['@vercel/analytics'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
async function getWebAnalyticsFunctions({
|
async function getWebAnalyticsFunctions({
|
||||||
root,
|
root,
|
||||||
logger,
|
logger,
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { getRedirects } from '../lib/redirects.js';
|
||||||
import { generateEdgeMiddleware } from './middleware.js';
|
import { generateEdgeMiddleware } from './middleware.js';
|
||||||
import {
|
import {
|
||||||
getInjectableWebAnalyticsContent,
|
getInjectableWebAnalyticsContent,
|
||||||
|
getWebAnalyticsViteConfig,
|
||||||
type VercelWebAnalyticsConfig,
|
type VercelWebAnalyticsConfig,
|
||||||
} from '../lib/web-analytics.js';
|
} from '../lib/web-analytics.js';
|
||||||
import {
|
import {
|
||||||
|
@ -172,7 +173,8 @@ export default function vercelServerless({
|
||||||
server: new URL('./dist/', config.root),
|
server: new URL('./dist/', config.root),
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
...getSpeedInsightsViteConfig(speedInsights?.enabled),
|
...getWebAnalyticsViteConfig(webAnalytics?.enabled || analytics),
|
||||||
|
...getSpeedInsightsViteConfig(speedInsights?.enabled || analytics),
|
||||||
ssr: {
|
ssr: {
|
||||||
external: ['@vercel/nft'],
|
external: ['@vercel/nft'],
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
} from '../lib/speed-insights.js';
|
} from '../lib/speed-insights.js';
|
||||||
import {
|
import {
|
||||||
getInjectableWebAnalyticsContent,
|
getInjectableWebAnalyticsContent,
|
||||||
|
getWebAnalyticsViteConfig,
|
||||||
type VercelWebAnalyticsConfig,
|
type VercelWebAnalyticsConfig,
|
||||||
} from '../lib/web-analytics.js';
|
} from '../lib/web-analytics.js';
|
||||||
|
|
||||||
|
@ -91,7 +92,8 @@ export default function vercelStatic({
|
||||||
redirects: false,
|
redirects: false,
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
...getSpeedInsightsViteConfig(speedInsights?.enabled),
|
...getWebAnalyticsViteConfig(webAnalytics?.enabled || analytics),
|
||||||
|
...getSpeedInsightsViteConfig(speedInsights?.enabled || analytics),
|
||||||
},
|
},
|
||||||
...getImageConfig(imageService, imagesConfig, command),
|
...getImageConfig(imageService, imagesConfig, command),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue