Skip to content

Commit c5dee92

Browse files
committed
fix config loading
1 parent 80aa80f commit c5dee92

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

config-loader.mjs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,24 @@ try {
103103
// Get the directory of the current module
104104
const __filename = fileURLToPath(import.meta.url);
105105
const __dirname = path.dirname(__filename);
106-
const customConfigPath = path.join(__dirname, 'custom.config.mjs');
107106

108-
if (fs.existsSync(customConfigPath)) {
107+
// Try multiple possible locations for custom.config.mjs
108+
// 1. Same directory as config-loader.mjs (works in dev)
109+
// 2. Process working directory (works in build/preview)
110+
const possiblePaths = [
111+
path.join(__dirname, 'custom.config.mjs'),
112+
path.join(process.cwd(), 'custom.config.mjs'),
113+
];
114+
115+
let customConfigPath = null;
116+
for (const possiblePath of possiblePaths) {
117+
if (fs.existsSync(possiblePath)) {
118+
customConfigPath = possiblePath;
119+
break;
120+
}
121+
}
122+
123+
if (customConfigPath) {
109124
// Use dynamic import with file:// URL to prevent static analysis by Vite/Rollup
110125
const customConfigUrl = pathToFileURL(customConfigPath).href;
111126
const customModule = await import(customConfigUrl);

0 commit comments

Comments
 (0)