Files
claudemesh/apps/web/css-stub-loader.mjs
Alejandro Gutiérrez 80a6b8b50f fix(web): resolve Payload CMS build error with Node.js ESM loader
Payload CMS imports .css/.scss/.svg files that Node.js ESM can't handle
during page data collection. Added a custom ESM loader that stubs these
asset imports, fixing the build that has been broken since the upgrade.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:24:32 +01:00

11 lines
563 B
JavaScript

// Node.js ESM loader that stubs non-JS asset imports during Next.js page data collection.
// Payload CMS and its deps import .css/.scss/.svg files that Node.js can't handle.
const STUB_EXTENSIONS = ['.css', '.scss', '.sass', '.svg', '.png', '.jpg', '.jpeg', '.gif', '.ico', '.woff', '.woff2', '.ttf', '.eot'];
export function resolve(specifier, context, nextResolve) {
if (STUB_EXTENSIONS.some(ext => specifier.endsWith(ext))) {
return { url: 'data:text/javascript,export default ""', shortCircuit: true };
}
return nextResolve(specifier, context);
}