It seems that this plugin fails to import and compile CSS stylesheets imported within a component CSS itself like so:
@import 'file/from/node_modules.css';
This results in webpack erroring out with a syntax error since it doesn't know how to interpret the CSS file. If we follow Webpack's instructions to add a loader to handle this specific .css, the build error goes away but a browser error appears instead:
Uncaught TypeError: Failed to resolve module specifier "file/from/node_modules.css". Relative references must start with either "/", "./", or "../".
In Rollup, this just works whenever we use the @rollup/plugin-node-resolve plugin before the LWC plugin. Without that plugin the same issue occurs in Rollup.
It seems there should be 1 of 2 possible fixes:
- This webpack plugin needs to see CSS @import to files in node_modules and resolve it the same way it resolves CSS modules from node_modules, like
@import 'lwc-namespace/css-module';
- The webpack config be updated to help this plugin know how to import that file on its own at build time. It does not seem to like having a separate loader try to handle that file for it.
It seems that this plugin fails to import and compile CSS stylesheets imported within a component CSS itself like so:
This results in webpack erroring out with a syntax error since it doesn't know how to interpret the CSS file. If we follow Webpack's instructions to add a loader to handle this specific
.css, the build error goes away but a browser error appears instead:In Rollup, this just works whenever we use the
@rollup/plugin-node-resolveplugin before the LWC plugin. Without that plugin the same issue occurs in Rollup.It seems there should be 1 of 2 possible fixes:
@import 'lwc-namespace/css-module';