Is there a way to execute scripts that utilize css modules?
I am currently working on a typescript migration script that I would like to execute using ts-node
. The ideal scenario would be to keep the script's dependencies separate from the React components in my codebase, but unfortunately that is not the case. The script eventually imports React components along with css modules, causing ts-node
to fail due to its inability to comprehend css modules:
RenderableInline.tsx(4,20): error TS2307: Cannot find module './styles/RenderableInline.module.scss' or its corresponding type declarations.
Only webpack has the capability to understand and build css modules, thanks to the configuration done through a css-loader
.
The closest solution I found was jest, which allows for mocking css modules to enable importing these files without errors. Here is a link to the documentation: https://jestjs.io/docs/webpack.
What approach can I take to run a typescript script that depends on css modules? Is there a way to achieve this using ts-node
? Alternatively, does webpack offer a feature for executing scripts?