It would be nice to explain why you recommend this? #79

Closed
behrangsa opened this Issue Mar 10, 2012 · 7 comments

Comments

Projects
None yet
7 participants
@behrangsa

So on the home page you have mentioned that:

Import "bootstrap" in your SCSS file of choice to get all of Bootstrap's styles, mixins and variables! Don't use Sproket's //= require directives for SASS files, because they're horrible and will kill your cat.

Why are Sprocket's //= require directives horrible? Why do you prefer @import? That sentence is not any helpful at all. It is just confusing.

@bryanrite

This comment has been minimized.

Show comment
Hide comment
@bryanrite

bryanrite Mar 10, 2012

Sprockets compiles each file individually, so mixins or variables to set in one file do not work in another; hence, all the mixins and variables available via Bootstrap are not within the scope of your own files, so you can't use them.

Import basically imports the files together and then they are compiled, allowing you to override and use Bootstrap.

Sprockets compiles each file individually, so mixins or variables to set in one file do not work in another; hence, all the mixins and variables available via Bootstrap are not within the scope of your own files, so you can't use them.

Import basically imports the files together and then they are compiled, allowing you to override and use Bootstrap.

@thomas-mcdonald

This comment has been minimized.

Show comment
Hide comment
@thomas-mcdonald

thomas-mcdonald Mar 28, 2012

Member

Fixed in 2.0.2. Links to that rather excellent explanation, in fact.

Member

thomas-mcdonald commented Mar 28, 2012

Fixed in 2.0.2. Links to that rather excellent explanation, in fact.

@tombh

This comment has been minimized.

Show comment
Hide comment
@tombh

tombh Jul 18, 2012

Sorry if this is misinformed; but then doesn't this mean that you lose the performance improvements of only having to recompile the single SASS file that's been changed, when in a development environment? I suspect that not using sprockets (in order to use mixins) is the reason I have to wait ~2-3 seconds each time I want to recompile my CSS.

EDIT: Aha! Think I found a really nice solution; instead of having to @import "bootstrap"; in every scss file, I'm just doing that in my main.scss and then doing;

@import "bootstrap/variables";
@import "bootstrap/mixins";

whenever I need mixins in scope. I've got < 100ms compile times again :)

tombh commented Jul 18, 2012

Sorry if this is misinformed; but then doesn't this mean that you lose the performance improvements of only having to recompile the single SASS file that's been changed, when in a development environment? I suspect that not using sprockets (in order to use mixins) is the reason I have to wait ~2-3 seconds each time I want to recompile my CSS.

EDIT: Aha! Think I found a really nice solution; instead of having to @import "bootstrap"; in every scss file, I'm just doing that in my main.scss and then doing;

@import "bootstrap/variables";
@import "bootstrap/mixins";

whenever I need mixins in scope. I've got < 100ms compile times again :)

@denschub denschub referenced this issue in diaspora/diaspora-project-site Jul 15, 2013

Closed

[WIP] Use bootstrap-sass instead of the static bootstrap.css + general cleanups #33

1 of 7 tasks complete
@namiwang

This comment has been minimized.

Show comment
Hide comment
@namiwang

namiwang Nov 22, 2013

@tombh That's a nice solution! But after that why we still using @import instead of =require in the main manifest file?

@tombh That's a nice solution! But after that why we still using @import instead of =require in the main manifest file?

@tombh

This comment has been minimized.

Show comment
Hide comment
@tombh

tombh Nov 22, 2013

@namiheike It's so long ago now, I'm not sure I remember! I think it's because if you use =require then the mixins aren't included.

tombh commented Nov 22, 2013

@namiheike It's so long ago now, I'm not sure I remember! I think it's because if you use =require then the mixins aren't included.

@jabr

This comment has been minimized.

Show comment
Hide comment
@jabr

jabr Feb 23, 2015

Is there an @import way to do the equivalent of Sprocket's = require_tree?

jabr commented Feb 23, 2015

Is there an @import way to do the equivalent of Sprocket's = require_tree?

@glebm

This comment has been minimized.

Show comment
Hide comment
@glebm

glebm Feb 23, 2015

Member

@jabr Glob imports (@import "a/**") are provided by sass-rails, and alternatively by sass-globbing. These are both for the ruby Sass, not sure if there is anything for libsass.

Member

glebm commented Feb 23, 2015

@jabr Glob imports (@import "a/**") are provided by sass-rails, and alternatively by sass-globbing. These are both for the ruby Sass, not sure if there is anything for libsass.

@cvrebert cvrebert locked and limited conversation to collaborators Feb 25, 2015

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.