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
|
// astro.config.mjs
|
||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from 'astro/config'
|
||||||
|
import react from '@astrojs/react'
|
||||||
|
import markdoc from '@astrojs/markdoc'
|
||||||
|
|
||||||
import react from '@astrojs/react';
|
// Only import keystatic and node in development
|
||||||
import markdoc from '@astrojs/markdoc';
|
let keystatic, node
|
||||||
import keystatic from '@keystatic/astro'
|
|
||||||
|
|
||||||
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
|
const isProduction = process.env.NODE_ENV === 'production'
|
||||||
export default defineConfig({
|
|
||||||
integrations: [react(), markdoc(), keystatic()],
|
|
||||||
|
|
||||||
adapter: node({
|
const config = {
|
||||||
mode: 'standalone',
|
output: isProduction ? 'static' : 'server',
|
||||||
}),
|
integrations: [react(), markdoc()]
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (!isProduction) {
|
||||||
|
config.adapter = node({ mode: 'standalone' })
|
||||||
|
config.integrations.push(keystatic())
|
||||||
|
}
|
||||||
|
|
||||||
|
export default defineConfig(config)
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"build": "astro build",
|
"build": "NODE_ENV=production astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"astro": "astro",
|
"astro": "astro",
|
||||||
"lint": "eslint . --ext .js,.ts,.astro",
|
"lint": "eslint . --ext .js,.ts,.astro",
|
||||||
|
|||||||
Reference in New Issue
Block a user