-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Is there way to use static images in styles folder? #369
Comments
Since static files are served from the root of the app server, what if you just tried Edit: Unless those static images aren't actually within |
@davezuko : Using just @xquezme : What you can do is: Put the image in a folder which is not the static folder (because the static folder is for assets that are not required anywhere in the source code, and all url(...) expression in (s)css files are processed by webpack which means they are required), let's assume you put it in ~/src/assets/images/ Then:
.pattern {
background-image: url('assets/images/pattern.jpg');
}
.someStyle {
composes: pattern from 'styles/pattern.scss';
height: 50px;
width: 50px;
} That works, because now url-loader will be able to locate the image and bundle it correctly. Edit: Same as davezuko - if those static images aren't actually within ~/src/static and are in ~/src/styles/static, this does not apply. |
Actually it is:
Thanks @SimonSelg, but IMO it's better to use one source for handling static files. |
Maybe we can add an example, like in the counter page, have a banner image or something, and this is reference in the styles. That way, we know where and how to use it. |
Will be adding an example once some of the current issues are fixed. |
@SimonSelg working on an example and am myself struggling with a clean implementation. The I've been incredibly swamped w/ work and only just today managed to push up a bunch of fixes, so I'll try to look into url-loader sometime later today, but wanted to ping you just in case you had any other ideas. |
Moving to FAQ. |
/styles/pattern.scss
/components/SomeComponent.scss
Work as expected (btw, only with precss), but as global:
Can't resolve file.
The text was updated successfully, but these errors were encountered: