Skip to content
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

Source maps generation #1777

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

MohammadYounes
Copy link
Contributor

  1. Make sure generated source maps are not inline.

    As of postcss 3.0 map.inline is enabled by default, which will cause source maps to be embedded inside the processed file.

  2. Respect Scss.GenerateSourceMaps flag.

  3. Respect Css.GenerateRtlSourceMaps flag.

To ensure services compatibility in the future, May be the build task should fix the major version of the downloaded node packages.

Related: #1726

Thanks.

@MohammadYounes
Copy link
Contributor Author

@madskristensen
Copy link
Owner

This PR can't be merged. Can you rebase and try again?
@am11 does it look good to you?

@MohammadYounes
Copy link
Contributor Author

@madskristensen done.

var map = result.map.toString();
var map, css = result.css.toString();
if (!options.omitSourceMapUrl)
map = result.map.toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

  • omitSourceMapUrl option in node-sass does not indicate the presence of source-map, but only the URL.
  • In Web Essentials, we need source-maps in all cases for editor enhancements.

I didn't think of autoprefixer use case before, where it would not be able to update the map file accordingly (since sourceMappingURL acts as a bridge). For that matter, we would need to inject the sourceMappingURL here to CSS:

var css = result.css.toString();  
var map = result.map.toString(); 
var appendix;

if (!options.omitSourceMapUrl) {
    appendix = '\n/*# sourceMappingURL= ' + params.mapFileName + ' */';
    css += appendix;
}

Then later on:

- css = autoprefixedOutput.css;
+ css = autoprefixedOutput.css.replace(appendix, '');

- RtlContent: rtlResult.css,
+ RtlContent: rtlResult.css.replace(appendix, ''),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@am11 This has nothing to do with autoprefixer being able to update the existing map. I used the flag because it indicates if source map generation is requested or not ( omitSourceMapUrl equals params.sourceMapURL === undefined).

If source maps generation is always enabled, then why its conditional in both autoprefixer and rtlcss ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it indicates if source map generation is requested or not

Wrong. Please re-read my previous comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to input/output params, not node-sass!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???
I totally lost you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more clear if I had wrote it like this :

var map, css = result.css.toString();
if (params.sourceMapURL !== undefined)
  map = result.map.toString();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said earlier, the compiler services (which support sourcemap, exception being LiveScript), should return source map to Web Essentials in all cases. WE then uses source-maps for editor extensibility features.
If sourcemap in autoprefixer is conditional, then that is a (separate) bug.
If sourcemap in RTLCss is conditional, then that is by design (because rtlcss result are returned separately).
Therefore, the real issue here is that the post-processed source-maps should overwrite those generated by node-based compiler, but it should respect the user-intended params.sourceMapURL option. And hence, the solution I described above would fix it. If you are still unconvinced, you can checkout the changes in srv-scss, as this is slightly out of scope for this PR. I will take care of it once the WE solution starts building again.

@am11
Copy link
Contributor

am11 commented Apr 30, 2015

I have left a comment. Other than that bit, @MohammadYounes has better understanding of postcss. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants