Comments (30)
Setting icon path works, but you need to prefix the path with a ~:
$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
@import "bootstrap-sass/assets/stylesheets/_bootstrap.scss";
If you don't add the ~ then it gets translated to ./bootstrap-sass/assets/fonts/bootstrap.
Thanks!
from sass-loader.
I found that setting $bootstrap-sass-asset-helper: true
instead of using $icon-font-path
solved the issue; $icon-font-path
was not really helping.
from sass-loader.
👍
from sass-loader.
hi all. i got the same error as @kurtharriger then tried the solution he presents, BUT... i then get the following error (filepaths specific to my system omitted via elipsis):
... Module not found: Error: Cannot resolve module 'file' ....
... Module not found: Error: Cannot resolve module 'url' in ...
these are the import statements i'm using:
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';
@import '~bootstrap-sass/assets/stylesheets/_bootstrap.scss';
and i have bootstrap-sass
installed in my node_modules
directory.
anyone have any guesses as to what's going on or possible fixes?
from sass-loader.
👍
from sass-loader.
@danpantry thank you! I searched high and low. only if this was in the README the search would not have been needed. Can update the README?
$bootstrap-sass-asset-helper: true;
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
from sass-loader.
exists a variable that fix the problem with the relative/absolute path, all that you need is set the variable $bootstrap-sass-asset-helper
in true
and that's all.
PS: do that before the importation of bootstrap:
$bootstrap-sass-asset-helper: true;
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
from sass-loader.
answered my own question (which i'll leave here in case anyone else encounters the same problem:
$ npm install file-loader --save
$ npm install url-loader --save
from sass-loader.
This worked for me:
@import "~bootstrap-sass/assets/stylesheets/_bootstrap-sprockets.scss";
@import "~bootstrap-sass/assets/stylesheets/_bootstrap.scss";
from sass-loader.
but why doesn't @import "bootstrap" work?
Would love an explanation for why we need the work around!
from sass-loader.
I don't know what the correct settings are, but you probably need to adjust the $icon-font-path
-variable. Bootstrap provides the possibility to configure the path to the icon fonts. Make sure that the url() is pointing from the imported file (probably /assets/stylesheets/_bootstrap.scss
in your case) to the font-files.
from sass-loader.
You need to think from the css-loader's perspective. It gets a css-file with url() statements referencing files. Now you need to start from the css-file's location and walk the relative url to the file and look if the path is correct.
from sass-loader.
Thanks to @danpantry, $bootstrap-sass-asset-helper
solve the problem, set the $icon-font-path
wasn't working
from sass-loader.
@jhnns The note on that section specifically mentions $icon-font-path
, which in this case is a red herring (I specifically noted that that did not work in my original comment). I suspect many people had consulted that documentation before searching for this issue..
from sass-loader.
but why doesn't @import "bootstrap" work?
And also why isn't $bootstrap-sass-asset-helper: true;
the default?
from sass-loader.
As far as I can tell the relative path to the font files from _bootstrap.scss is correct. I didn't know the icon path could be specified before import, so Ill give that a try. I was thinking that sass-loader would/should resolve the relative urls and it would just work?
I don't intend to customize bootstrap at the moment so if I still have issues I'll just copy the precompiled in for now. I just figured using the sass-loader would simplify packaging.
Thanks
from sass-loader.
Ah okay now I get it. Perhaps the sass loader could update the resulting css, but not entirely sure how easy that would be. Probably need to use the source map to determine original path or maybe it would be easier to update path prior to processing so output is correct?
Now I understand why the relative path doesn't just work. Thanks
from sass-loader.
Related discussions: sass/sass#1015 sass/libsass#532
You could also try this sass mixin to achieve relative urls.
from sass-loader.
Thanks a lot!
from sass-loader.
$bootstrap-sass-asset-helper
might also work. However, setting $icon-font-path
relative to the scss entry file does also work. I'm using this setting in my projects.
from sass-loader.
There is a test for bootstrap. It must be related to your local config.
from sass-loader.
@danpantry answer is the best $bootstrap-sass-asset-helper
option, if anybody else stumbles here.
from sass-loader.
@danpantry Thanks man. You are a life-saver.
from sass-loader.
There's a note about this problem at https://github.com/jtangelder/sass-loader#problems-with-url. Why was this not helpful? We have a test for bootstrap: https://github.com/jtangelder/sass-loader/blob/master/test/scss/bootstrap-sass.scss
from sass-loader.
Thanks @danpantry . Saved my time 👍
from sass-loader.
Thanks @Grievoushead. Your solution worked for me.
from sass-loader.
I had a $icon-font-path: '../old/path !default'
in code which prevented from assigning any other values to $icon-font-path
..
from sass-loader.
@moiguitarrock, looking at the network requests, it looks like this setting sets url to an outside server hosting the files instead of the local ones bundled in with webpack.
from sass-loader.
@JohnGallego I don't see this behaviour on my local
from sass-loader.
I need to know the same answer as @teknicalissue wants to know.
from sass-loader.
Related Issues (20)
- [Windows]: [email protected] will throw a python not found error HOT 36
- VueJs is not compiling parent selector HOT 1
- Document outputStyle is set to compressed in production mode HOT 4
- Styles for styles.scss block is not defined HOT 1
- Custom sass functions suddenly do not work? Or the API has changed? HOT 1
- Node Sass 9.0.0 HOT 1
- Before publish to npm , 'prepare' scripts should be removed HOT 15
- Potential Security Vulnerabilities Detected in Package
- error HOT 2
- SCSS Not compile functions properly.
- Missing version upgrade/migration guides HOT 1
- Use the Sass Compiler API HOT 4
- Update v10 to allow use node-sass@9 HOT 3
- Unable to use meta.get-mixin to pass mixin as a value to another mixin, then use it in its content. HOT 2
- v10.5.1 still not support node-sass 9 HOT 1
- Make it easier to prefer `sass-embedded` over `sass` HOT 2
- Global variable scope when using `additionalData` option HOT 3
- sass error while compiling semantic ui css file HOT 2
- webpack condition is not accepted when loading from packages HOT 3
- I try to import custom theme and want to use css file in scss using @use but its got error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sass-loader.