Im converting a web app from CJS to ESM.
The web app is bundled with webpack, but the first page load is rendered on the backend by node.js.
In the app I import CSS like this:
import style from './Body.module.css';
Currently (now that Ive switched to running ESM on node.js) that gives me this error:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" for [retracted]/Body.module.css
Previously I was using ignore-styles to make sure node.js doesn’t crash, but that’s a Babel loader.
And apparently Babel doesnt work with ESM imports so I switched to TSX.
I tried node-hook but that’s also a patch for require, it doesnt work for import statements.
Any recommendations how I can avoid this error when importing a .module.css
file? Or any .css
file?
Ideally I’d even get the same class names as webpack in node.js, but that might be a separate question.