-
Notifications
You must be signed in to change notification settings - Fork 12k
fix(@angular-devkit/build-angular): load component source maps inline… #11729
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
fix(@angular-devkit/build-angular): load component source maps inline… #11729
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
@@ -267,7 +267,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) { | |||
options: { | |||
ident: buildOptions.extractCss ? 'extracted' : 'embedded', | |||
plugins: postcssPluginCreator, | |||
sourceMap: cssSourceMap | |||
sourceMap: cssSourceMap ? 'inline' : false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming based on the linked issue that you meant to change the source map configuration for component styles located here and not the global styles config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually both are affected by the problem, but I had missed that there were 2 instances of postcss-loader. With each using 'inline' instead of a boolean, both the global maps and component maps are now working. I updated the commit and the commit message to reflect that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is the case then the comment in this section is very relevant. style-loader
1.0 (unreleased) automatically handles the source maps in this regard. As a stopgap this appears to be an acceptable solution. However, if the global stylesheets are extracted, they should not contain inline source maps. The conditional in this case should set the value to true
if source maps and extraction are enabled; inline
if only source maps are enabled; and false
otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought about that, but when I tried ng build --source-map --extract-css
without the inline sourcemaps, they did not work. The chrome inspector just referenced the generated css files. Looking a bit further, it does generate a map file for the styles, but there are no mappings to the scss files in it.
dist/styles.css.map
{"version":3,"sources":[],"names":[],"mappings":"","file":"styles.css","sourceRoot":""}
There may be another bug happening on top of this, although the always inline will resolve it as is until it's found. I suppose that's up to you whether you want extracted sourcemaps broken until it's found or supplement it as is (always inline if true) until then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted stylesheets should have working source maps. If they are not working that would be a separate issue. Altering the behavior for extracted souremaps in this way would be require a major version bump as end users may not realize the source maps are embedded resulting in the source being pushed unknowingly in production builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will still only push source maps if --source-map is explicitly set, but I suppose your point may be relevant if people are building source maps and then manually pulling the map files from their build as part of a deployment process which I would consider unorthodox. I do agree that its a separate issue, but its also related to the referenced issue since it isn't completely resolved until the extracted scss source maps also work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are willing to make the suggested change, we should be able to roll this into the next minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I should be able to get that in today. Just to confirm, the component styles are always injected inline via js even with extract-css, so the change just goes on the global styles, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is up.
4e569e5
to
7ab661c
Compare
7ab661c
to
84ec302
Compare
f130a0d
to
ba22a3b
Compare
ba22a3b
to
f46869d
Compare
3e8992b
to
50eb452
Compare
Sorry about the close and re-open. I had my gitlab account in my config when I rebased and reverting closed this. Everything should be good to go now, though, as long as the rebase fixed those failed tests. |
…they work without this, the way styles are into the DOM breaks the default sourcemap option postcss-loader option docs https://github.com/postcss/postcss-loader#inline fixes angular#9099
50eb452
to
7a0165c
Compare
@clydin A couple of rebases later and the appveyor CI finally passed. All automated checks are good, just needing approval. |
is it possible to port this to version |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
… so they work
without this, the way styles are into the DOM breaks the default sourcemap option
postcss-loader option docs
https://github.com/postcss/postcss-loader#inline
fixes #9099