11import mdx from '@astrojs/mdx'
2- import preact from '@astrojs/preact'
32import sitemap from '@astrojs/sitemap'
43import vercelStatic from '@astrojs/vercel'
5- import sentry from " @sentry/astro"
4+ import sentry from ' @sentry/astro'
65import tailwindcss from '@tailwindcss/vite'
76import AstroPWA from '@vite-pwa/astro'
87import vtbot from 'astro-vtbot'
98import icon from 'astro-icon'
109import { defineConfig } from 'astro/config'
10+ import { fileURLToPath } from 'node:url'
11+ import type { PluginOption } from 'vite'
1112/**
1213 * You cannot use path aliases (@lib, @components, etc.) in files that are
1314 * imported by astro.config.ts, because the path alias resolution happens
@@ -32,6 +33,21 @@ import { packageRelease } from './src/integrations/PackageRelease'
3233import { privacyPolicyVersion } from './src/integrations/PrivacyPolicyVersion'
3334import { createSerializeFunction , pagesJsonWriter } from './src/integrations/sitemapSerialize'
3435
36+ const disablePwaIntegration = process . env [ 'DISABLE_PWA' ] ?. toLowerCase ( ) === 'true'
37+ const enableRollupLogger = process . env [ 'DEBUG_ROLLUP' ] ?. toLowerCase ( ) === 'true'
38+
39+ const rollupImportLogger = ( ) : PluginOption => ( {
40+ enforce : 'pre' ,
41+ name : 'rollup-import-logger' ,
42+ resolveId ( source , importer ) {
43+ if ( source . includes ( 'rollup' ) || source === 'vite' || source . startsWith ( 'vite/' ) || source . includes ( 'vite/dist' ) ) {
44+ console . info ( '[rollup-import]' , source , importer )
45+ }
46+
47+ return null
48+ } ,
49+ } )
50+
3551export default defineConfig ( {
3652 adapter : vercelStatic ( vercelConfig ) ,
3753 devToolbar : {
@@ -42,20 +58,19 @@ export default defineConfig({
4258 * Astro sets substantial Vite config internally in the framework. When you use Vitest
4359 * in an Astro project, you use Astro's getViteConfig helper to get the resolved internal
4460 * Vite syntax along with any Vite syntax set in this astro.config.ts file. Since integrations
45- * can change config, they're ran when the helper's called. This causes problems for
61+ * can change config, they're ran when the helper's called. This causes problems for
4662 * unit testing integrations.
4763 */
4864 integrations : isUnitTest ( ) ? [ ] : [
49- AstroPWA ( serviceWorkerConfig ) ,
65+ ... ( disablePwaIntegration ? [ ] : [ AstroPWA ( serviceWorkerConfig ) ] ) ,
5066 icon ( ) ,
5167 mdx ( markdownConfig ) ,
52- preact ( { devtools : true } ) ,
5368 /** Generate favicons and PWA icons from source SVG */
5469 faviconGenerator ( ) ,
5570 /** Verify number of call to actions included in Markdown files */
5671 callToActionValidator ( {
5772 /** Enable debug logging to see validation details */
58- debug : true
73+ debug : true ,
5974 } ) ,
6075 /** Inject package release (name@version) for tracking regressions between releases */
6176 packageRelease ( ) ,
@@ -87,13 +102,23 @@ export default defineConfig({
87102 /** Source map generation must be turned on for Sentry. */
88103 sourcemap : true ,
89104 } ,
105+ define : {
106+ /**
107+ * LightningCSS exposes a WASM build via require('../pkg'), which Vite cannot
108+ * resolve when bundling for the browser. Setting this flag to false at build
109+ * time lets Rollup tree-shake the problematic branch.
110+ */
111+ 'process.env.CSS_TRANSFORMER_WASM' : 'false' ,
112+ } ,
90113 /* @ts -expect-error - tailwindcss plugin type compatibility */
91- plugins : [ tailwindcss ( ) ] ,
92- /**
93- * Note: The "astro:transitions sourcemap" warning is cosmetic and can be safely
94- * ignored. It occurs because the transitions plugin transforms code without
95- * generating sourcemaps. This doesn't affect build functionality, runtime
96- * performance, or debugging capabilities
97- */
114+ plugins : [
115+ tailwindcss ( ) ,
116+ ...( enableRollupLogger ? [ rollupImportLogger ( ) ] : [ ] ) ,
117+ ] as PluginOption [ ] ,
118+ resolve : {
119+ alias : {
120+ fsevents : fileURLToPath ( new URL ( './src/shims/fsevents.ts' , import . meta. url ) ) ,
121+ } ,
122+ } ,
98123 }
99124} )
0 commit comments