Files
astro-note-template/astro.config.mjs
xiongxiao b00b4a69a7 init
2026-03-21 20:32:27 +08:00

64 lines
1.5 KiB
JavaScript

// @ts-check
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
import path from 'path';
import react from '@astrojs/react';
import tailwindcss from '@tailwindcss/vite';
import pkgs from './package.json';
import dotenv from 'dotenv';
const env = dotenv.config().parsed || {};
const isDev = env.NODE_ENV === 'development' || process.env.NODE_ENV === 'development';
const basename = isDev ? '/' : pkgs?.basename || '/';
let target = env.VITE_API_URL || process.env.API_URL || 'http://localhost:51515';
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
let proxy = {
'/root/': apiProxy,
'/api': apiProxy,
'/client': apiProxy,
};
// https://astro.build/config
export default defineConfig({
base: basename,
integrations: [
starlight({
title: 'Note',
social: [],
sidebar: [
{
label: 'Guides',
items: [
// Each item here is one entry in the navigation menu.
{ label: 'Example Guide', slug: 'guides/example' },
],
},
{
label: 'Reference',
autogenerate: { directory: 'reference' },
},
],
customCss: [
'./src/styles/global.css',
],
}),
react(), //
],
server: {
port: 7008,
host: '0.0.0.0',
allowedHosts: true,
},
vite: {
// @ts-ignore
plugins: [tailwindcss()],
define: {
BASE_NAME: JSON.stringify(basename || ''),
},
server: {
proxy,
},
},
});