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>
11 lines
563 B
JavaScript
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);
|
|
}
|