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'>;
|
||||
};
|
||||
|
||||
export function getWebAnalyticsViteConfig(enabled?: boolean) {
|
||||
if (enabled) {
|
||||
return {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
external: ['@vercel/analytics'],
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
async function getWebAnalyticsFunctions({
|
||||
root,
|
||||
logger,
|
||||
|
|
|
@ -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'],
|
||||
},
|
||||
|
|
|
@ -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),
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue