Giter VIP home page Giter VIP logo

meteor-scss's Introduction

Sass for Meteor

This is a Sass build plugin for Meteor. It compiles Sass files with node-sass and it has options to control the load order of Sass files and use Autoprefixer on the generated CSS.

Installation

Install using Meteor's package management system:

> meteor add fourseven:scss

If you want to use it for your package, add it in your package control file's onUse block:

Package.onUse(function (api) {
  ...
  api.use('fourseven:scss');
  ...
});

Compatibility

Meteor VersionRecommended fourseven:scss version
1.0 - 1.13.2.0
1.2 - 1.3.13.4.2
1.3.2+3.8.0
1.4.03.8.1
1.4.1+3.10.0

Since meteor 1.4.1+ (fourseven:scss 3.9.0+), we do not have prebuild binaries anymore. You are required to set up the required toolchain yourselves.

Note that due to a bug in libsass, there is currently no support for the old, indented sass syntax

Usage

Without any additional configuration after installation, this package automatically finds all .scss and .sass files in your project, compiles them with node-sass, and includes the resulting CSS in the application bundle that Meteor sends to the client. The files can be anywhere in your project.

File types

There are two different types of files recognized by this package:

  • Sass sources (all *.scss and *.sass files that are not imports)
  • Sass imports/partials, which are:
    • files that are prefixed with an underscore _
    • marked as isImport: true in the package's package.js file: api.addFiles('x.scss', 'client', {isImport: true})
    • Starting from Meteor 1.3, all files in a directory named imports/

The source files are compiled automatically (eagerly loaded). The imports are not loaded by themselves; you need to import them from one of the source files to use them.

The imports are intended to keep shared mixins and variables for your project, or to allow your package to provide several components which your package's users can opt into one by one.

Each compiled source file produces a separate CSS file. (The standard-minifiers package merges them into one file afterwards.)

Importing

You can use the regular @import syntax to import any Sass files: sources or imports.

Besides the usual way of importing files based on the relative path in the same package (or app), you can also import files from other packages or apps with the following syntax.

Importing styles from a different package:

@import "{my-package:pretty-buttons}/buttons/_styles.scss";

.my-button {
  // use the styles imported from a package
  @extend .pretty-button;
}

Importing styles from the target app:

@import "{}/client/styles/imports/colors.scss";

.my-nav {
  // use a color from the app style pallete
  background-color: @primary-branding-color;
}

Sourcemaps

These are on by default.

Autoprefixer

As of Meteor 1.2 autoprefixer should preferably be installed as a separate plugin. You can do so by running:

meteor remove standard-minifiers
meteor add seba:[email protected]

In a Meteor 1.3+ project, do the same by running:

meteor remove standard-minifier-css
meteor add seba:minifiers-autoprefixer

LibSass vs Ruby Sass

Please note that this project uses LibSass. LibSass is a C++ implementation of the Ruby Sass compiler. It has most of the features of the Ruby version, but not all of them. Things are improving, so please be patient. Before you ask, I have no intention of making a version of this package that links to the Ruby version instead.

For a quick rundown on what libsass does and doesn't (currently) do, check here.

meteor-scss's People

Contributors

fourseven avatar sebakerckhof avatar amclin avatar naycon avatar lourd avatar znerol avatar andrefgneves avatar rohanray avatar brunolemos avatar gabrielpoca avatar ianserlin avatar jpunt avatar wizonesolutions avatar chuangbo avatar sachag avatar scottmcpherson avatar reywood avatar sbking avatar s7dhansh avatar timche avatar wimatihomer avatar

Watchers

James Cloos avatar Randell S. Hynes avatar

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.