2024-06-14 02:11:26 +08:00
|
|
|
import mdx from '@astrojs/mdx';
|
|
|
|
import node from '@astrojs/node';
|
|
|
|
import { defineConfig, envField } from 'astro/config';
|
2024-06-19 03:34:36 +08:00
|
|
|
import options from './options';
|
|
|
|
import { astroImage } from './plugins/images';
|
2024-06-20 22:41:40 +08:00
|
|
|
import { uploader } from './plugins/uploader';
|
2024-06-14 02:11:26 +08:00
|
|
|
|
|
|
|
// https://astro.build/config
|
|
|
|
export default defineConfig({
|
2024-06-19 03:34:36 +08:00
|
|
|
// This will override the import.meta.env.SITE. No need to introduce method.
|
|
|
|
site: options.isProd() ? options.website : options.local.website,
|
2024-06-14 02:11:26 +08:00
|
|
|
output: 'server',
|
|
|
|
security: {
|
|
|
|
checkOrigin: true,
|
|
|
|
},
|
2024-06-21 00:17:18 +08:00
|
|
|
image: {
|
|
|
|
domains: ['localhost', '127.0.0.1'],
|
2024-06-21 01:09:13 +08:00
|
|
|
service: !options.isProd() ? { entrypoint: './plugins/resize', config: {} } : undefined,
|
2024-06-21 00:17:18 +08:00
|
|
|
},
|
2024-06-14 02:11:26 +08:00
|
|
|
experimental: {
|
|
|
|
env: {
|
|
|
|
schema: {
|
2024-06-19 03:34:36 +08:00
|
|
|
// Postgres Database
|
2024-06-14 02:11:26 +08:00
|
|
|
POSTGRES_HOST: envField.string({ context: 'server', access: 'secret' }),
|
|
|
|
POSTGRES_PORT: envField.number({ context: 'server', access: 'secret' }),
|
|
|
|
POSTGRES_USERNAME: envField.string({ context: 'server', access: 'secret' }),
|
|
|
|
POSTGRES_PASSWORD: envField.string({ context: 'server', access: 'secret' }),
|
|
|
|
POSTGRES_DATABASE: envField.string({ context: 'server', access: 'secret' }),
|
2024-06-19 03:34:36 +08:00
|
|
|
// Artalk Comment
|
2024-06-17 02:56:39 +08:00
|
|
|
ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }),
|
2024-06-14 02:11:26 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
integrations: [
|
|
|
|
mdx({
|
|
|
|
remarkPlugins: [astroImage],
|
|
|
|
}),
|
2024-06-20 22:41:40 +08:00
|
|
|
uploader({
|
|
|
|
paths: ['images', 'og', 'cats'],
|
|
|
|
endpoint: process.env.S3_ENDPOINT,
|
|
|
|
bucket: process.env.S3_BUCKET as string,
|
|
|
|
accessKey: process.env.S3_ACCESS_KEY as string,
|
|
|
|
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY as string,
|
2024-06-19 03:34:36 +08:00
|
|
|
}),
|
2024-06-14 02:11:26 +08:00
|
|
|
],
|
|
|
|
adapter: node({
|
|
|
|
mode: 'standalone',
|
|
|
|
}),
|
|
|
|
markdown: {
|
|
|
|
gfm: true,
|
|
|
|
shikiConfig: {
|
|
|
|
theme: 'solarized-light',
|
|
|
|
wrap: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
server: {
|
2024-06-19 03:34:36 +08:00
|
|
|
port: options.local.port,
|
2024-06-14 02:11:26 +08:00
|
|
|
},
|
|
|
|
devToolbar: {
|
|
|
|
// I don't need such toolbar.
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
vite: {
|
|
|
|
// Add this for avoiding the needless import optimize in Vite.
|
|
|
|
optimizeDeps: { exclude: ['@napi-rs/canvas'] },
|
|
|
|
},
|
2024-06-19 03:34:36 +08:00
|
|
|
build: {
|
|
|
|
assets: 'cats',
|
|
|
|
assetsPrefix: options.assetsPrefix(),
|
|
|
|
},
|
2024-06-14 02:11:26 +08:00
|
|
|
});
|