This repository has been archived on 2025-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
Files
astro-template/astro.config.mjs
2025-11-24 12:56:34 +08:00

44 lines
1.1 KiB
JavaScript

import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import react from '@astrojs/react';
import sitemap from '@astrojs/sitemap';
import pkgs from './package.json';
import tailwindcss from '@tailwindcss/vite';
import dotenv from 'dotenv';
dotenv.config();
const isDev = process.env.NODE_ENV === 'development';
let target = process.env.VITE_API_URL || 'http://localhost:51015';
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
let proxy = {
'/root/': {
target: `${target}/root/`,
},
'/api': apiProxy,
'/client': apiProxy,
};
const basename = isDev ? undefined : `${pkgs.basename}`;
export default defineConfig({
base: basename,
integrations: [
mdx(),
react(), //
// sitemap(), // sitemap must be site has a domain
],
vite: {
plugins: [tailwindcss()],
define: {
BASE_NAME: JSON.stringify(basename || ''),
},
server: {
port: 7008,
host: '0.0.0.0',
allowedHosts: true,
proxy,
},
},
});