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

Generate a sourcemap #109

Open
bartveneman opened this issue Dec 21, 2024 · 0 comments
Open

Generate a sourcemap #109

bartveneman opened this issue Dec 21, 2024 · 0 comments

Comments

@bartveneman
Copy link
Member

bartveneman commented Dec 21, 2024

I have a use case for tracking old and new string indexes of the before + after CSS.

This could also be done via a callback, like this, but sourcemaps are more elegant, I guess?

let positions = new Map<[number, number], [number,number]>
let new_css = fomat(old_css, { 
  on_node: function (node: csstree.CssNode, start_pos: number, end_pos: number }) {
    positions.set([node.loc.start.offset, node.loc.end.offset], [start_pos, end_pos])
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant