-
Notifications
You must be signed in to change notification settings - Fork 12k
Relative url('..') in scss files cannot be resolved #5752
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
I would like to make it very clear, that when explicitly using CSS (instead of SCSS) by doing the following:
then everything works. |
you may have an error in your scss file. I had the same |
No, that was just to mask off the actual file system path. Please take the paths as layed out in the "Repro steps." section. They are very exact and very explicitly these paths written there. |
@httpdigest Could you please push the relevant parts of your code to a repo and share? |
@demirk4n please see the exhaustive and complete "Repro steps." steps in the initial post. It contains every necessary step to reproduce the case and takes only half a minute to setup. |
Looks like the section Problems with url(...) in the sass-loader README.md describes this exact problem and a possible solution, using the resolve-url-loader. |
Okay, using the 'resolve-url-loader' completely resolves my issue. The relevant part in const commonLoaders = [
// css-loader doesn't support webpack.LoaderOptionsPlugin properly,
// so we need to add options in its query
`css-loader?${JSON.stringify({ sourceMap: cssSourceMap, importLoaders: 1 })}`,
'resolve-url-loader', // <- this is new!
'postcss-loader'
]; Then after a Currently, we now rely on patching webpack's models/webpack-configs/styles.js in a npm postinstall step. It'd be nice if this can be added into Webpack itself. |
I am using css, and i have the same issue. ERROR in ./src/app/hotel-search/firstpage-search/firstpage-search.component.css |
As it turned out, the issue I was having was related to (and only related to) SCSS, which can be fixed by using the resolve-url-loader. |
Having this same issue with scss. As a work-around, I use a root reference like this: |
We're also having the same issue attempting to import the Materialize CSS SASS library. We're unable to use the work-around mentioned by @zakdances because the library isn't under our control.
Outcome: +1 for adding a feature to angular cli to include the resolve-url-loader for SASS relative path resolution. |
@httpdigest would you be interested in making a PR that adds your proposed change (#5752 (comment))? |
Actually, now I remember why I didn't add This issue is actually a duplicate of #5213, my response can be found at #5213 (comment). |
@filipesilva I'm facing the same problem as @luketn, this is preventing me to migrate an app to angular-cli |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions.
Output from:
ng --version
:Repro steps.
ng new url-test
cd url-test
src/theme/images
andsrc/theme/styles
src/theme/styles/mystyle.scss
with the content:body { background: url('../images/background.png'); }
src/theme/images/background.png
being any PNG image@import './theme/styles/mystyle.scss';
ng build
The log given by the failure.
Desired functionality.
What would [you] like to see implemented?
Currently, the behaviour when specifically using SCSS is different from using CSS. When using CSS (styles.css and mystyle.css) then everything works and the background.png image is found.
This should be the same when using SCSS.
What is the usecase?
Using SCSS instead of CSS for more expressiveness in an obviously more complex application than the one provided here.
The text was updated successfully, but these errors were encountered: