Files
nearle_daily_admin_web/tools/css-hooks.mjs
2026-09-28 17:24:00 +05:30

20 lines
864 B
JavaScript

/**
* Make `import './thing.css'` a no-op under the Node test runner.
*
* Vite turns a CSS import into a side effect that injects a stylesheet; Node
* has no such notion and refuses the file outright with
* ERR_UNKNOWN_FILE_EXTENSION. That is fine for the pure tests, which never
* import a component — but the map has to be MOUNTED to be tested at all, and
* leaflet's own stylesheet comes with it.
*
* Styling is not what those tests check. They count polylines and markers in
* the document, which leaflet creates regardless of whether any CSS loaded. So
* every `.css` specifier resolves to an empty module and the import vanishes.
*/
export function resolve(specifier, context, next) {
if (specifier.endsWith('.css')) {
return { url: 'data:text/javascript,export default {}', shortCircuit: true };
}
return next(specifier, context);
}