@@ -10,7 +10,7 @@ import vtbot from 'astro-vtbot'
1010import { defineConfig } from 'astro/config'
1111import type { AstroUserConfig } from 'astro'
1212import { fileURLToPath } from 'node:url'
13- import type { PluginOption } from 'vite'
13+ import { createLogger , type LogOptions , type PluginOption } from 'vite'
1414/**
1515 * You cannot use path aliases (`@lib`, `@components`, etc.) in files that are
1616 * imported by astro.config.ts, because the path alias resolution happens
@@ -40,6 +40,27 @@ import { createSerializeFunction, pagesJsonWriter } from './src/integrations/sit
4040
4141// Ensure Vite's HMR websocket connects through the same exposed dev server port used by Astro.
4242const devServerPort = Number ( process . env [ 'DEV_SERVER_PORT' ] ?? 4321 )
43+ const viteLogger = createLogger ( undefined , { allowClearScreen : false } )
44+
45+ const shouldSuppressViteWarning = ( message : string ) : boolean => {
46+ return (
47+ / r e s o l v e \. a l i a s .* c u s t o m R e s o l v e r o p t i o n / i. test ( message ) ||
48+ (
49+ / e x t e r n a l i z e d f o r b r o w s e r c o m p a t i b i l i t y / i. test ( message ) &&
50+ / n o d e _ m o d u l e s \/ (?: @ a s t r o j s \/ v e r c e l | @ a s t r o j s \/ i n t e r n a l - h e l p e r s | @ v e r c e l \/ | e s b u i l d \/ l i b \/ m a i n \. j s | @ m a p b o x \/ n o d e - p r e - g y p | n o d e - g y p - b u i l d | d e t e c t - l i b c | g r a c e f u l - f s | b i n d i n g s | r e s o l v e - f r o m | f i l e - u r i - t o - p a t h | n o p t ) \/ / i. test ( message )
51+ )
52+ )
53+ }
54+
55+ const shouldSuppressRollupWarning = ( warning : {
56+ code ?: string | undefined
57+ plugin ?: string | undefined
58+ } ) : boolean => {
59+ return (
60+ warning . code === 'SOURCEMAP_BROKEN' &&
61+ warning . plugin === '@tailwindcss/vite:generate:build'
62+ )
63+ }
4364
4465const standardIntegrations = [
4566 AstroPWA ( pwaConfig ) ,
@@ -99,8 +120,8 @@ export default defineConfig({
99120 * unit testing integrations.
100121 */
101122 integrations : standardIntegrations ,
102- /** API routes are marked in their files for SSR */
103- output : 'static ' ,
123+ /** Astro actions require server output in Astro 6. Individual routes can still opt into prerendering. */
124+ output : 'server ' ,
104125 prefetch : true ,
105126 image : {
106127 remotePatterns : [
@@ -115,6 +136,13 @@ export default defineConfig({
115136 site : getSiteUrl ( ) ,
116137 trailingSlash : 'never' ,
117138 vite : {
139+ customLogger : {
140+ ...viteLogger ,
141+ warn : ( message : string , options ?: LogOptions ) => {
142+ if ( shouldSuppressViteWarning ( message ) ) return
143+ viteLogger . warn ( message , options )
144+ } ,
145+ } ,
118146 server : {
119147 hmr : {
120148 clientPort : devServerPort ,
@@ -135,6 +163,12 @@ export default defineConfig({
135163 build : {
136164 /** Source map generation must be turned on for Sentry. */
137165 sourcemap : true ,
166+ rollupOptions : {
167+ onwarn ( warning , warn ) {
168+ if ( shouldSuppressRollupWarning ( warning ) ) return
169+ warn ( warning )
170+ } ,
171+ } ,
138172 } ,
139173 define : {
140174 /**
@@ -156,10 +190,4 @@ export default defineConfig({
156190 } ,
157191 } ,
158192 } ,
159- experimental : {
160- /**
161- * Generate your styles and scripts in the order they are defined, instead of reversing them
162- */
163- preserveScriptOrder : true ,
164- } ,
165193} )
0 commit comments