Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does @import 'compass' includes the whole framework?

Tags:

compass-sass

I started to importing shared things like variables and mixins in one place - css manifest file. Now I'm importing some Compass mixins using direct path to the files.

My question is if using @import 'compass' injects the whole framework into application.css or is it done by looking by references in sass files and then importing only needed mixins?

I don't want to include everything.

like image 745
wryrych Avatar asked Aug 22 '13 08:08

wryrych


People also ask

What is Compass SCSS?

Compass is a stylesheet authoring framework that makes your stylesheets and markup easier to build and maintain. With compass, you write your stylesheets in Sass instead of plain CSS.

How do I import a compass into CSS?

Getting started with Compass scss file. For example, to import the CSS3 module we'd use: @import "compass/css3"; Now we can start using the utilities and mixins that Compass offers for the new properties that came with CSS3.


1 Answers

According to the docs @import 'compass' will import CSS3, Typography and Utilities modules. These modules won't inject anything into your output CSS, they contain only mixins.

By limiting import to a specific module or submodule (i.e. @import 'compass/css3/image') you will reduce the time required to compile your SASS files into CSS.


For example, lets create two files.

// all.scss

@import "compass";

.candy {
  @include background(linear-gradient(top left, #333, #0c0));
}
// module.scss

@import "compass/css3/images";

.candy {
  @include background(linear-gradient(top left, #333, #0c0));
}

If we compile them (compass compile sass/FILENAME.scss), result CSS will be identical:

.candy {
  background: -webkit-gradient(linear, 0% 0%, 100% 100%, color-stop(0%, #333333), color-stop(100%, #00cc00));
  background: -webkit-linear-gradient(top left, #333333, #00cc00);
  background: -moz-linear-gradient(top left, #333333, #00cc00);
  background: -o-linear-gradient(top left, #333333, #00cc00);
  background: linear-gradient(top left, #333333, #00cc00);
}

Now lets add --time argument to the compilation command and compare the results. For my machine, it took 1.516 s to compile all.css vs only 0.108 s for module.css.

like image 195
Pavlo Avatar answered Oct 03 '22 20:10

Pavlo