Sass integration for Ember CLI

11.0.1 · active · verified Wed Apr 22

Ember CLI Sass is an addon for Ember CLI applications that integrates Sass preprocessing into the build pipeline. It provides robust support for generating source maps, configuring include paths, and handling multiple CSS output files via Ember CLI's `outputPaths` configuration. Currently stable at version 11.0.1, the package is actively maintained with recent releases addressing internal chore items and node version compatibility. It defaults to using Dart Sass (compiled to pure JavaScript) for compilation but offers explicit configuration to utilize alternative implementations like `node-sass` (which uses LibSass for potentially faster compilation), allowing developers to choose based on their project's performance and dependency needs. It is a fundamental tool for styling Ember.js projects with Sass, ensuring seamless integration with the Ember CLI build system.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates `ember-cli-sass` installation and basic configuration within `ember-cli-build.js`, including `sassOptions` for include paths and an example of multiple CSS output paths.

/* ember-cli-build.js */
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const defaults = require('lodash.defaultsdeep');

// Optional: If you want to use node-sass for potentially faster compilation
// const nodeSass = require('node-sass');

module.exports = function(env) {
  let app = new EmberApp(defaults(env.APP, {
    // Configure ember-cli-sass options here
    sassOptions: {
      // implementation: nodeSass, // Uncomment to use node-sass
      includePaths: [
        'app/styles',
        'node_modules/my-ui-library/scss'
      ],
      sourceMap: true, // Defaults to true in development
      extension: 'scss' // Defaults to 'scss'
    },

    // Example for processing multiple SASS files
    outputPaths: {
      app: {
        css: {
          app: '/assets/application-name.css',
          'themes/alpha': '/assets/themes/alpha.css' // Compile app/styles/themes/alpha.scss
        }
      }
    }
  }));

  return app.toTree();
};

/* app/styles/app.scss */
@import 'variables';
body {
  font-family: sans-serif;
  color: $primary-color;
}

/* app/styles/_variables.scss */
$primary-color: #336699;

view raw JSON →