File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
packages/astro/src/content Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' astro ' : patch
3+ ---
4+
5+ Fix ` import.meta.env.DEV ` always being set to ` true ` when using Content Collections
Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ export async function loadContentConfig({
190190 settings : AstroSettings ;
191191} ) : Promise < ContentConfig | Error > {
192192 const contentPaths = getContentPaths ( { srcDir : settings . config . srcDir } ) ;
193+ const nodeEnv = process . env . NODE_ENV ;
193194 const tempConfigServer : ViteDevServer = await createServer ( {
194195 root : fileURLToPath ( settings . config . root ) ,
195196 server : { middlewareMode : true , hmr : false } ,
@@ -206,6 +207,9 @@ export async function loadContentConfig({
206207 return new NotFoundError ( 'Failed to resolve content config.' ) ;
207208 } finally {
208209 await tempConfigServer . close ( ) ;
210+ // Reset NODE_ENV to initial value
211+ // Vite's `createServer()` sets NODE_ENV to 'development'!
212+ process . env . NODE_ENV = nodeEnv ;
209213 }
210214 const config = contentConfigParser . safeParse ( unparsedConfig ) ;
211215 if ( config . success ) {
You can’t perform that action at this time.
0 commit comments