-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PostCSS doesn't update SourceMaps properly when an input file is in a subdirectory #13
Comments
I ran into the same issue when I developed my fork of Autoprefixer with source maps support. Here is how I solved the problem and the relevant test. If any of that helps ;) (I must admit that is not the most well-written code I've produced -.-) I wonder if the source-map module could be smarter about this by default, though ... |
@lydell thanks, it will be very helpful :). |
Maybe we should commit to source-map? After few days I will start to fix this issue and I try to find how it will be difficult. |
I think it has to do with that the |
There is problem, that path.relative() only in Node.js :(. But we can use some smart autodetect and didn’t use this method in browsers. |
@ai what about browserify shim? |
You are cool guys :). Thanks, that is what I need. Hopy, that mozilla team would like to add new dependencie :). |
Проблему с обновлением mappings в grunt-autoprefixer обошел переходом в папку from, чтобы input (from) путь состоял только из имени файла — https://github.com/nDmitry/grunt-autoprefixer/blob/master/tasks/autoprefixer.js#L66:L69 Короче, в переводе на консольный интерфейс из этого: В этом случае mappings при имеющейся входящей карте обновляются корректно, хотя в file и sources тогда пути всё равно неправильные, поэтому их тоже пришлось указывать вручную: https://github.com/nDmitry/grunt-autoprefixer/blob/master/tasks/autoprefixer.js#L47:L55 |
Perhaps the second argument of |
I tried changing the
As you can see, the source is now changed to "a.sass", but the path to "a.sass" should be relative to the source map (as @nDmitry’s expected output shows). This is how I understand the problem:
So, here is what I think needs to be done:
/cc @fitzgen |
@lydell you are awesome :D thanks for good investigation. |
Here is the test for |
Assuming that there's tests, docs, and nice code, I'll accept a PR that adds the extra parameter to |
That looks exactly like |
@lydell second argument for |
As far as I understand, your fix and using the second argument are equivalent. They both partially solve the problem: The Last Friday I started working on improving the |
@lydell does I understand correct, that next problem is that we use apsolute path in map, but must use paths relative from map file? I try to fix it in |
Source maps are free to use both absolute and relative paths. If they are relative, they should be relative to the source map itself. That's the problem. When we apply the previous map, the sources paths of that map will be put in our new map. But they will still be relative to the previous map. That's a bug in the |
@ai just do what I did in grunt-autoprefixer or wait for the
Also I don't want to look at all that CoffeeScript (sorry, it makes me sick =)), but make sure that your tests actually test mappings. |
@nDmitry don’t be so cruel with CoffeeScript ;). There are a lot of execulent software on Ruby and Python with same code style :). @lydell I think to take now path hacks from grunt-autoprefixer and clean them when |
Sounds sensible 👍 |
@nDmitry @lydell I think I have done with relative paths :). Can you please check last 2 tests. |
Looks good! Good idea to hack fix this for the time being. I did get time to work on my patch yesterday, but I ran into several unexpected problems. |
Expected output:
The text was updated successfully, but these errors were encountered: