57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
// @ts-check
|
||
import { defineConfig, envField } from 'astro/config';
|
||
import { fileURLToPath } from 'node:url';
|
||
|
||
import tailwindcss from '@tailwindcss/vite';
|
||
|
||
import alpinejs from '@astrojs/alpinejs';
|
||
|
||
|
||
import node from '@astrojs/node';
|
||
|
||
|
||
// https://astro.build/config
|
||
export default defineConfig({
|
||
vite: {
|
||
plugins: [tailwindcss()],
|
||
resolve: {
|
||
alias: {
|
||
// 路径别名:@ -> 项目 src 目录(与 tsconfig paths 一致)
|
||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||
},
|
||
},
|
||
},
|
||
|
||
i18n: {
|
||
defaultLocale: 'en',
|
||
locales: ['en', 'cn'],
|
||
routing: {
|
||
prefixDefaultLocale: true, // 英文在根路径 /shows,中文在 /cn/shows
|
||
},
|
||
},
|
||
|
||
build: {
|
||
// 示例:在构建过程中生 成`page.html` 而不是 `page/index.html`。
|
||
// format: 'file'
|
||
},
|
||
|
||
integrations: [alpinejs()],
|
||
|
||
adapter: node({
|
||
mode: 'standalone'
|
||
}),
|
||
|
||
// 环境变量声明:统一命名规范
|
||
// BASE_API —— 公开/运行期 API 基址(浏览器 + 按需渲染共用,空 = 同源 /api)
|
||
// BASE_API_SSG —— 构建期 SSG 内部端口基址(仅服务端,绝不进前端 bundle)
|
||
// SSG_TOKEN —— SSG 内部接口可选访问令牌(仅服务端)
|
||
// 注意:Astro 仅自动把 PUBLIC_ 前缀变量暴露给客户端,BASE_API 没有该前缀,
|
||
// 故必须在 schema 中声明为 access:'public',否则浏览器端 import.meta.env.BASE_API 为 undefined。
|
||
env: {
|
||
schema: {
|
||
BASE_API: envField.string({ context: 'client', access: 'public', optional: true }),
|
||
BASE_API_SSG: envField.string({ context: 'server', access: 'secret', optional: true }),
|
||
SSG_TOKEN: envField.string({ context: 'server', access: 'secret', optional: true }),
|
||
},
|
||
},
|
||
}); |