Added environment-dependent astro.config.mjs
All checks were successful
Build and Deploy Astro Site / deploy (push) Successful in 23s
All checks were successful
Build and Deploy Astro Site / deploy (push) Successful in 23s
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
// @ts-check
|
||||
import { defineConfig } from 'astro/config';
|
||||
// astro.config.mjs
|
||||
import { defineConfig } from 'astro/config'
|
||||
import react from '@astrojs/react'
|
||||
import markdoc from '@astrojs/markdoc'
|
||||
|
||||
import react from '@astrojs/react';
|
||||
import markdoc from '@astrojs/markdoc';
|
||||
import keystatic from '@keystatic/astro'
|
||||
// Only import keystatic and node in development
|
||||
let keystatic, node
|
||||
|
||||
import node from '@astrojs/node';
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
keystatic = (await import('@keystatic/astro')).default
|
||||
node = (await import('@astrojs/node')).default
|
||||
}
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
integrations: [react(), markdoc(), keystatic()],
|
||||
const isProduction = process.env.NODE_ENV === 'production'
|
||||
|
||||
adapter: node({
|
||||
mode: 'standalone',
|
||||
}),
|
||||
});
|
||||
const config = {
|
||||
output: isProduction ? 'static' : 'server',
|
||||
integrations: [react(), markdoc()]
|
||||
}
|
||||
|
||||
if (!isProduction) {
|
||||
config.adapter = node({ mode: 'standalone' })
|
||||
config.integrations.push(keystatic())
|
||||
}
|
||||
|
||||
export default defineConfig(config)
|
||||
Reference in New Issue
Block a user