Code Monkey home page Code Monkey logo

Comments (30)

kurtharriger avatar kurtharriger commented on May 18, 2024 235

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.

punmechanic avatar punmechanic commented on May 18, 2024 95

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.

jhnns avatar jhnns commented on May 18, 2024 51

👍

from sass-loader.

aguestuser avatar aguestuser commented on May 18, 2024 43

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.

sahil87 avatar sahil87 commented on May 18, 2024 42

👍

from sass-loader.

6zz avatar 6zz commented on May 18, 2024 41

@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.

moiguitarrock avatar moiguitarrock commented on May 18, 2024 39

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.

aguestuser avatar aguestuser commented on May 18, 2024 21

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.

SerhiiKozachenko avatar SerhiiKozachenko commented on May 18, 2024 17

This worked for me:

@import "~bootstrap-sass/assets/stylesheets/_bootstrap-sprockets.scss";
@import "~bootstrap-sass/assets/stylesheets/_bootstrap.scss";

from sass-loader.

calcazar avatar calcazar commented on May 18, 2024 9

but why doesn't @import "bootstrap" work?

Would love an explanation for why we need the work around!

from sass-loader.

jhnns avatar jhnns commented on May 18, 2024 6

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.

jhnns avatar jhnns commented on May 18, 2024 5

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.

albttx avatar albttx commented on May 18, 2024 5

Thanks to @danpantry, $bootstrap-sass-asset-helper solve the problem, set the $icon-font-path wasn't working

from sass-loader.

punmechanic avatar punmechanic commented on May 18, 2024 4

@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.

lorencole avatar lorencole commented on May 18, 2024 2

but why doesn't @import "bootstrap" work?

And also why isn't $bootstrap-sass-asset-helper: true; the default?

from sass-loader.

kurtharriger avatar kurtharriger commented on May 18, 2024

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.

kurtharriger avatar kurtharriger commented on May 18, 2024

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.

jhnns avatar jhnns commented on May 18, 2024

Related discussions: sass/sass#1015 sass/libsass#532

You could also try this sass mixin to achieve relative urls.

from sass-loader.

osasseville avatar osasseville commented on May 18, 2024

Thanks a lot!

from sass-loader.

jhnns avatar jhnns commented on May 18, 2024

$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.

jhnns avatar jhnns commented on May 18, 2024

There is a test for bootstrap. It must be related to your local config.

from sass-loader.

akras14 avatar akras14 commented on May 18, 2024

@danpantry answer is the best $bootstrap-sass-asset-helper option, if anybody else stumbles here.

from sass-loader.

seancheung avatar seancheung commented on May 18, 2024

@danpantry Thanks man. You are a life-saver.

from sass-loader.

jhnns avatar jhnns commented on May 18, 2024

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.

satyaprakash-k avatar satyaprakash-k commented on May 18, 2024

Thanks @danpantry . Saved my time 👍

from sass-loader.

arvinsim avatar arvinsim commented on May 18, 2024

Thanks @Grievoushead. Your solution worked for me.

from sass-loader.

tsuz avatar tsuz commented on May 18, 2024

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.

JohnGallego avatar JohnGallego commented on May 18, 2024

@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.

monarchwadia avatar monarchwadia commented on May 18, 2024

@JohnGallego I don't see this behaviour on my local

from sass-loader.

ChristianGalvez23 avatar ChristianGalvez23 commented on May 18, 2024

I need to know the same answer as @teknicalissue wants to know.

from sass-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.