-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@import CSS stylesheets from node_modules aren't compiled #36
Comments
Here's a StackBlitz with a minimal reproducible setup, showing the working Rollup config and the broken Webpack config: https://stackblitz.com/edit/salesforce-lwc-bsr9jh?file=webpack.config.js |
We did discover a workaround for this issue, though I wonder if this is expected configuration or if it's still an issue for this plugin: module: {
rules: [
{
test: /node_modules\/@salesforce-ux\/.+?\.css$/i,
use: ['style-loader', 'css-loader']
}
]
} The above is running @import '@salesforce-ux/sds-common/common.css'; Note: this is different from how LWC handles @import wes/styles; The above line works fine with this plugin, even when the LWC CSS module is installed in |
Nevermind, the above issue was enabling our build to work, but it prevented LWC from actually rendering the stylesheets on the page. This is still an open issue |
Here's what did it: modules: [
{
npm: '@sfdc-www/digital-i18n',
},
{
dir: 'node_modules', // <-- 0_0
},
{
npm: '@sfdc-www/wes-lwc-components',
},
{
npm: '@sfdc-www/idx-auth-ui',
},
{
dir: 'src/elements',
}, The magic is that But this feels dirty. This is wrong, right? Or is this intended? Are there downsides to allowing LWC to try to resolve modules from any NPM package? |
That's really strange @cvharris. I imagine this is some subtle interplay between LWC's module resolver and how Webpack's style loader works. But if it works, it works! |
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-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:
@import 'lwc-namespace/css-module';
The text was updated successfully, but these errors were encountered: