-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Error "module build failed" when importing with @angular/cli #981
Comments
Looks like this is a known issue with sass-loader: webpack-contrib/sass-loader#466 What I don't understand is how the |
@yeelan0319 unfortunately this does not solve the problem for me, as I am using Angular CLI 😢 And that is actually what this issue is about. Regarding the documentation: IMHO it's missing specific information about how to configure Webpack. This seems to be exactly the line I mentioned from material-components' own includePaths: glob.sync('node_modules/@material/*').map((d) => path.join(__dirname, d)) Why not include that directly in the README, instead of just a vague statement that Likewise for people using node-sass directly - IMHO it would be much more helpful to have a concrete code snippet. |
good point @mischkl. I also think the README should be more precise. Unfortunately your guess doesn't work either. To make it up and running you have to try something like that:
|
Havret's suggestion is how we use it in our toolchain. Try that and see if it works. |
Again as mentioned in the description, I can't try the suggestion using an angular-cli project. Perhaps there is a way but it's not documented. I guess no one seems to care because Angular users by and large will choose angular-material components. But it still doesn't make this issue any more fixed. |
It's not that no one cares, it's that it is not really a thing that is broken in MDC Web. I did a quick google search to see if anyone else was running into a similar issue, and the method used in the second to last comment in this thread appears to have worked for that user. Anything past that I think you'll have better luck on Stack Overflow or asking the folks over at Angular CLI |
If you look carefully at that last suggestion it means that every individual package path has to be added to the config, and there's no possibility to use one of the MDC Web group packages since they won't be able to resolve their dependencies. So not only does every component need to be added and versioned individually but also added and maintained individually in the angular-cli config. And as far as I can tell there's no benefit to doing this over using it the I have some trouble accepting the answer that "it's not really an MDC Web problem" because I honestly can't tell what kind of setup you're expecting people to use that actually works? Node-sass or original ruby sass plus some dependency resolving plugin? eyeglass? Or are you attempting to target webpack in a roundabout way? if so I'd say that the problem is the sass-loader plug-in. but without having a "reference build setup" to compare the behavior with I can't say. |
Hey @mischkl, our recommendation would be to just use the MDC libraries listed on our README built specifically for Angular, i.e. Angular MDC or Blox Material. MDC Web is a foundational library designed to be extended for use in other JS frameworks, so that developers will use the MDC library specific to their framework. |
Thanks for the tip. Looking at the Blox Material getting started guide, it seems the magic solution is simply to add the following to the "stylePreprocessorOptions": {
"includePaths": [
"../node_modules"
]
} I'll try testing this and posting the result tomorrow. If it turns out to work it might be nice for you to add that to your documentation, as it would seem the mentioned libraries are completely optional and only add a bit more convenience. |
This one worked for me on Angular 7.x:
You must nclude the same |
Guys, i love that feeling. Day wasted, but solution is found |
What MDC-Web Version are you using?
0.3.10
What browser(s) is this bug affecting?
All
What OS are you using?
Linux (Fedora 23), Node v6.11.0, npm v5.2.0
What are the steps to reproduce the bug?
Start an
@angular/cli
project, install for instance@material/select
, and add following tostyles.scss
.Run project with
npm start
What is the expected behavior?
It should compile fine.
What is the actual behavior?
The following error is output:
Any other information you believe would be useful?
A simple modification of the
mdc-select.scss
file makes it possible to import it correctly: Simply adding~
to the package imports.However I'm hesitant to submit my own pull request, since it would impact every component package.
The text was updated successfully, but these errors were encountered: