Skip to content

fix: enhance prebuild output directory configuration #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/presets/src/presets/astro/prebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ async function prebuild() {
const newOutDir = '.edge/storage';
let outDir = 'dist';

// check if an output path is specified in config file
const configFileContent = await readFile('./astro.config.mjs', 'utf-8');
const attributeMatch = Array.from(configFileContent.matchAll(/outDir:(.*)\n/g), (match) => match)[0];
// check if an output path is specified in config file (support .ts then .mjs)
let configFileContent: string;
try {
configFileContent = await readFile('./astro.config.ts', 'utf-8');
} catch {
configFileContent = await readFile('./astro.config.mjs', 'utf-8');
}
const attributeMatch = Array.from(
configFileContent.matchAll(/outDir:(.*)\n/g),
(match) => match
)[0];
if (attributeMatch) {
outDir = attributeMatch[1].trim();
}
Expand Down
Loading