-
-
Notifications
You must be signed in to change notification settings - Fork 608
Root option on the Windows system. #526
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
Comments
@sagorshkov can you create minimal reproducible test repo? |
@evilebottnawi I've created a simple example with my case. |
@sagorshkov why do your store |
@evilebottnawi It's a long story)) It's a simple example, but I need to use relative paths in the sass and get absolute paths in result CSS. I found only one way to do it - using css-loader's root option and got this case(( |
@sagorshkov absolute path => |
@evilebottnawi Sorry, more precisely so: in sass I have to use "/images/" paths, and in the result CSS I need to get path relative to this CSS file, something like this "../assets/images/". Because of For URLs that start with a /, the default behavior is to not translate them, I use root option. |
And to resolve this asset I use absolute path to working directory as root option. |
@sagorshkov on linux works as expected https://github.com/sagorshkov/css-loader-demo ? |
@sagorshkov seems bug in https://github.com/webpack-contrib/css-loader/blob/master/lib/processCss.js#L125 [ { type: 'url',
url: 'C:UsersIEUser\rownloads\fss-loader-demo-master/images/star.png' } ]
[ { type: 'url',
url: 'C:UsersIEUser\rownloads\fss-loader-demo-master/images/star.png' } ] |
/cc @michael-ciniawsky should we wait new |
/cc @sagorshkov also https://github.com/sagorshkov/css-loader-demo/blob/master/webpack.config.js#L47 seems not compatibility with windows paths https://regex101.com/r/CZg28i/1, just use |
depending if you have something in mind to fix it already 😛 everything we can fix let's fix it nevertheless |
@michael-ciniawsky this PR #523 should fix this issue because we drop |
but be good add tests for this |
Just ping for review when ready :D LTGM so far, btw I think I will port it to my originally proposed |
Please don't use |
Uh oh!
There was an error while loading. Please reload this page.
Hello. I'm using root option to resolve relative paths in my css.
My architecture is: css loader uses root option to prepend my dirname's absolute path to the relative URLs in css. After, this URLs resolve with file-loared (file loader is finding the assets using
those absolute path).
For examle I've tried something like this:
options:{
root: __dirname
}
also I've tried:
options:{
root: path.resolve(__dirname)
}
Both of these work well on OS X and Linux systems.
But on Windows don't.
There is next error there:
ERROR in ./~/css-loader?{"root":"C://Projects//project-name","sourceMap":true,"minimize":false}!./~/sass-loader/lib/loader.js!./src/styles/entry.scss
.Module not found: Error: Can't resolve 'C:Projectsproject-name/images/image.png' in 'C:\Projects\project-name\src\styles'
In logs root option is
{"root":"C://Projects//project-name"}
But in resolving path it is
C:Projectproject-name
Looks like all slashes was removed from URL's prefix of root option.
Could you help me with this issue, please? What I'm doing wrong?
Thanks in advance.
The text was updated successfully, but these errors were encountered: