Skip to content

fix: allow inlined sourceMaps when sourceMap or devtool are truthy #475

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

Closed
wants to merge 2 commits into from

Conversation

alan-agius4
Copy link

@alan-agius4 alan-agius4 commented Sep 8, 2020

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

Previously when either the sourceMap option or devtool was truthy
inlining of sourceMaps was not possible.

Breaking Changes

Additional Info

@codecov
Copy link

codecov bot commented Sep 8, 2020

Codecov Report

Merging #475 into master will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #475      +/-   ##
==========================================
- Coverage   97.50%   97.48%   -0.02%     
==========================================
  Files           5        5              
  Lines         240      239       -1     
  Branches       76       77       +1     
==========================================
- Hits          234      233       -1     
  Misses          6        6              
Impacted Files Coverage Δ
src/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 792e217...e3d89d0. Read the comment docs.

Previously when either the sourceMap option or devtool was truthy
inlining of sourceMaps was not possible.
{
sourceMap: true,
postcssOptions: {
sourceMap: true,
Copy link
Member

Choose a reason for hiding this comment

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

No need 👍

processOptions.map = { inline: false, annotation: false };
if (
typeof processOptions.map === 'undefined' ||
typeof processOptions.map === 'boolean'
Copy link
Member

@alexander-akait alexander-akait Sep 8, 2020

Choose a reason for hiding this comment

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

processOptions.map: true means as the same postcss(plugins).process(content, { from, map: true }), there is not docs for this, but it should generate inline map as I remember

Copy link
Author

@alan-agius4 alan-agius4 Sep 8, 2020

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

To generate a new source map with the default options, simply set map: true. This will generate an inline source map that contains the source content. If you don’t want the map inlined, you can set map.inline: false.

processOptions.map = { inline: true };
}

processOptions.map.prev = sourceMap;
Copy link
Member

@alexander-akait alexander-akait Sep 8, 2020

Choose a reason for hiding this comment

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

Also it is breaking change, now you need always to set sourceMap: true if you need source maps, but it is invalid , in some cases I don't need webpack source maps, I need only postcss source maps (for example generate library with css and relative urls in sources)

Copy link
Author

Choose a reason for hiding this comment

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

Maybe I can amend the logic to check for either useSourceMaps or postcssOptions.map?

Copy link
Member

Choose a reason for hiding this comment

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

What do you want to achieve? I don't understand what you are trying to do, if you want to generate inline source map just set postcssOptions.map: true

Copy link
Author

Choose a reason for hiding this comment

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

At the moment if devtool is set you cannot “inline” a sourcemap.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I understood the problem, I'm working on it

@alexander-akait
Copy link
Member

alexander-akait commented Sep 8, 2020

@alan-agius4 After this PR #476 - you should not use sourceMap: true and postcssOptions.map together, this makes no sense, using the postcssOptions.map option enable source maps generation

@alan-agius4
Copy link
Author

Thanks

@alexander-akait
Copy link
Member

@alan-agius4 feel free to feedback

@alan-agius4
Copy link
Author

@evilebottnawi, the latest patch version fixes the problem. Thanks

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.

2 participants