-
Notifications
You must be signed in to change notification settings - Fork 232
Errors parsing CSS #348
Comments
That's because Could you provide the source file(s) causing this error for reference please? |
Ping @zoechi - I don't want to miss for |
It's a bit hard to tell what source causes this error. It's the MDL CSS. .mdl-color--accent {
background-color: unquote("rgb(#{$color-accent})") !important;
} |
When I check the content of the file in the browser, there is no |
It won't show in the browser because the CSS shim won't output it. Are you using the latest version of MDL? I ran it through the shim recently while fixing the last issue you posted and I didn't see this error, but I'll look again. |
I just checked the latest version of MDL and found this segment. .mdl-color--accent {
background-color: rgb(255, 64, 129) !important;
} This corresponds to the original SCSS it was compiled from, which is exactly the snippet you provided. Are you perhaps using the SCSS directly in your project? |
If I load http://localhost:63342/myproj/web/designer.css .mdl-color--accent {
background-color: rgb(255,64,129) !important; } but I still get the error in the transformer |
It seems like somehow the SCSS is being fed into the transformer. Is your project hosted somewhere so I could take a look? That link is to localhost so I can't see your CSS. |
Sorry, the localhost link wasn't supposed to work, I just wanted to show how I got the content (so that the browser or shims won't modify it) |
Alright thanks. Sorry you're running into this issue. Like I said, I suspect SCSS is being fed into the transformer in place of CSS somewhere. Are you using SCSS in your project and compiling it to CSS? |
Is there a chance it's outputting SCSS that is being fed into Angular? Do you have |
@leonsenft Where does |
See Configuration: https://github.com/dart-league/dart-sass#configuration |
I see :D. No, I'm not using it. I don't apply any options at all to the sass transformer. |
Sorry, without the actual project to look at I'm not sure how I can help you any further. As I said before this issue isn't a bug with the CSS parser, but rather a bug or misconfiguration with tooling that SCSS is ending up in the style compiler directly. |
@leonsenft I still plan to provide more information. Just wanted to get clarification on other question raised during the discussion. |
Okay great, I still absolutely want to help you resolve this issue. |
I was able to investigate more. The code complained about
seems to come back from the SASS transformer as shown in the error message, when the variables (like What's weird is, that |
So because the variable isn't defined, it's never replaced and remains in the CSS? The second issue you've described is because the transformer processes all CSS files in the project (and dependencies) #352. It's possible to exclude files from being processed in your pubspec.yaml, but this has to be done in the project containing the file itself, not from a dependent project. I'm going to close this issue because it's correctly reporting invalid CSS. There's discussion though about revising the approach taken with new CSS shimming to be less restrictive. |
Perhaps it shouldn't break the build on invalid CSS for files that don't concern it (not referenced in |
You're right, that's a valid concern which is covered by issue #352. |
@ok, great. Somehow missed the link. |
After being able to get rid of this error, I was able (or the new Angular version did - not sure) to fix some other problem that caused serious troubles since months (see for example #351). I didn't expect that above error really breaks the Angular build, but now it looks like it did. Now I have the suspicion that the broken CSS caused the problems all along and the updated CssLib just made it visible. When I remove the
and errors like this happened all the time. Here it complains about the template of a service!!! To me this now looks like changing the code and reloading made parts of the Angular transformer re-run which wasn't run previously because of the CSS problem (maybe because it threw an exception), It's one side to print error messages about stuff that is not correct, but another to break the build, and I think invalid CSS should not break the build. I think there is still some ugly issue hidden that can lead to really bad user experience, If this explanation is too confusing, please let me know and I try to improve. |
The broken CSS shouldn't have been responsible before we introduced the parser from csslib. Before everything was regex based, so it wouldn't even know if there was invalid CSS. What happens now, is we parse the CSS, then shim it by transforming the CSS AST. The issue is if csslib itself runs into an error parsing. It doesn't have very good error recovery, so rather than failing to shim a single selector, it has rather unpredictable results, but generally gives up on the rest of the file. We thought this should be a build error since it's unlikely if you had a CSS error that your component would look anything like you intended. But having CSS errors in files you're not using break the build is not very desirable behavior, so maybe we should revert the CSS errors to warnings. The issues are further exacerbated by csslib only accepting known at-rules with specific grammars, rather than performing more generalized parsing. Overall I'm not very happy with the amount of disruption this change has caused, as it was just intended to fix some bugs with the shim. I'm going to work on making the parser much more lenient in what it accepts which should eliminate this problem and the others like it. |
but when I remove the exclusion or
Build errors are usually very annoying. I don't want to be forced to have every character in the whole application perfect to be able to look at the result.
In the end it seems to have fixed (or at least revealed some insight about) an issue that was extremely frustrating. |
Angular2:
version: "3.0.0-beta+1"
The text was updated successfully, but these errors were encountered: