Snowpack with React and CSS modules bundled into JavaScript

291 Views Asked by At

I’m having an issue with Snowpack and CSS modules. When I build the app it creates a .json file with the hashed and non-hashed class names but they are not loaded into index.js and all the classes show as undefined when inspecting the page. When I look at the source I can see an empty object that looks like it should have the JSON in and if I add it manually it works... is there something I need to configure to get this to work or should it just do it after importing the xxx.module.css file?

Additionally is there a way to bundle the css in with the JavaScript so it injects the styles at runtime rather than having a separate css file? Maybe using @snowpack/webpack to bundle them?

Update: I just updated to the latest version of snowpack and it doesn’t even generate the .json file...

0

There are 0 best solutions below