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

Fix file path in source maps #250

Merged
merged 1 commit into from
Jun 26, 2016
Merged

Fix file path in source maps #250

merged 1 commit into from
Jun 26, 2016

Conversation

cevou
Copy link
Contributor

@cevou cevou commented May 27, 2016

There are currently two problems regarding source maps file path with this loader:

  1. The loader depends on self.options.output.path to be set. If you don't set this property the relative urls in line 281 is calculated wrong. By using the context this problem does not exist anymore.
  2. node-sass uses the directory in which the map file is created as root path. All source paths within the map are relative to this path. However, when webpack processes the sourcemaps it expects all paths to be relative to the webpack execution directory. To resolve all files correctly I added the sourceRoot property to express the relative path.

In combination with the suggested fix for the css-loader (webpack-contrib/css-loader#280) this produces nice paths for source maps, that reflect the actual file structure within the project.

@jhnns jhnns merged commit e0ce2b4 into webpack-contrib:master Jun 26, 2016
@jhnns
Copy link
Member

jhnns commented Jun 26, 2016

Thx! 👍

I probably need to change this again because a loader should not access webpack options

@jhnns
Copy link
Member

jhnns commented Jun 26, 2016

Shipped as 3.2.2

@billyross
Copy link

billyross commented Jun 27, 2016

Just wondering if it would be possible to retain the option of using output.path if present? I'm currently seeing a webpack build fail when loading font files...
ERROR in ./~/css-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/ no-op.js Module not found: Error: Cannot resolve 'file' or 'directory' ./fonts/vlook/6dfa3ef5-ebc5-4d23-a631-b3d746c2ad39.woff2 in C:\working\{distPath}\node_modules\bootstrap-loader @ ./~/css-loader!./~/resolve-url-loader!./~/sass-loader?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js!./~/bootstrap-loader/no-op. js 6:1131-1198

@cevou
Copy link
Contributor Author

cevou commented Jun 27, 2016

Do you have a sample configuration file with which the error could be reproduced?

@billyross
Copy link

Hi there, unfortunately I can't provide the exact configuration although it is essentially based on https://github.com/davezuko/react-redux-starter-kit.

With webpack.config here:
https://github.com/davezuko/react-redux-starter-kit/blob/master/build/webpack.config.js
Consts defined here:
https://github.com/davezuko/react-redux-starter-kit/blob/master/config/index.js.

I'd assume with this recent change that that project would have similar problems should custom fonts be loaded also.

@e-cloud
Copy link

e-cloud commented Jun 27, 2016

yes, it should be breaking change. I am facing the same error.

@bel0v
Copy link

bel0v commented Jun 27, 2016

same here

chrisnicola added a commit to WealthBar/a2d3 that referenced this pull request Jun 27, 2016
@cevou
Copy link
Contributor Author

cevou commented Jun 27, 2016

After some more investigation. This change indeed breaks the resolve-url-loader. As you can see in https://github.com/bholloway/resolve-url-loader/blob/master/index.js#L63 the loader assumes that the sass-loader outputs source maps relative to the output directory. This was changed with this pull request. So this pull request might be considered as a breaking change.
There are some changes needed in resolve-url-loader to fix this. First the outputPath needs to be changed to the context path. With this change it still doesn't work. The loader gets also confused by the sourceRoot property. I might check on this in the next couple of days.

For now this change breaks a lot of installations. Basically everyone who uses resolve-url-loader is effected. So we either need a quick fix in resolve-url-loader or need to revert this change for now and put it in a new version 4.0.

// cc: @bholloway, @jhnns

@bholloway
Copy link
Contributor

bholloway commented Jun 27, 2016 via email

@jhnns
Copy link
Member

jhnns commented Jun 27, 2016

Ok, I'll flag this version as broken, publish a new major release and then we can sort it out. No stress! 👍

@bholloway would you be open to make a PR to the sass-loader so that we have tests to check against the resolve-url-loader? Seems like more people are using it, so it would be nice to ensure compatibility. It was not obvious for me that this could be breaking change at all. If you do the PR, please mention me so I can merge it asap.

@jhnns
Copy link
Member

jhnns commented Jun 27, 2016

Shipped as 4.0.0

@cevou
Copy link
Contributor Author

cevou commented Jun 27, 2016

I created a pull request to resolve-url-loader to work again with the latest version. bholloway/resolve-url-loader#23

@bholloway
Copy link
Contributor

@jhnns given that you can't unpublish 3.2.2. Could you branch an orphan from tag 3.2.1 and re-release as 3.3.3.

It would make it easier to specify to my users sass-loader@<4 and it would definitely move the breaking change to 4.0.0.

@jhnns
Copy link
Member

jhnns commented Jul 5, 2016

@bholloway
Copy link
Contributor

Ah yes. Sorry I thought I read that somewhere but I didn't see it in the tags. I should have checked with npm.

All good.

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.

6 participants