Fix external dependency issue

This commit is contained in:
Chris 2023-09-06 13:45:59 +02:00
parent ad86e9f648
commit e492e948df
3 changed files with 20 additions and 2 deletions

View file

@ -9,6 +9,20 @@ export type VercelWebAnalyticsConfig = {
config?: Omit<AnalyticsProps, 'beforeSend'>;
};
export function getWebAnalyticsViteConfig(enabled?: boolean) {
if (enabled) {
return {
build: {
rollupOptions: {
external: ['@vercel/analytics'],
},
},
};
}
return {};
}
async function getWebAnalyticsFunctions({
root,
logger,

View file

@ -16,6 +16,7 @@ import { getRedirects } from '../lib/redirects.js';
import { generateEdgeMiddleware } from './middleware.js';
import {
getInjectableWebAnalyticsContent,
getWebAnalyticsViteConfig,
type VercelWebAnalyticsConfig,
} from '../lib/web-analytics.js';
import {
@ -172,7 +173,8 @@ export default function vercelServerless({
server: new URL('./dist/', config.root),
},
vite: {
...getSpeedInsightsViteConfig(speedInsights?.enabled),
...getWebAnalyticsViteConfig(webAnalytics?.enabled || analytics),
...getSpeedInsightsViteConfig(speedInsights?.enabled || analytics),
ssr: {
external: ['@vercel/nft'],
},

View file

@ -10,6 +10,7 @@ import {
} from '../lib/speed-insights.js';
import {
getInjectableWebAnalyticsContent,
getWebAnalyticsViteConfig,
type VercelWebAnalyticsConfig,
} from '../lib/web-analytics.js';
@ -91,7 +92,8 @@ export default function vercelStatic({
redirects: false,
},
vite: {
...getSpeedInsightsViteConfig(speedInsights?.enabled),
...getWebAnalyticsViteConfig(webAnalytics?.enabled || analytics),
...getSpeedInsightsViteConfig(speedInsights?.enabled || analytics),
},
...getImageConfig(imageService, imagesConfig, command),
});