David Chan David Chan - 1 year ago 121
Sass (Sass) Question

Is it possible to pass environment variables to Ember cli sass during build?

I am using ember-cli-sass

I want to define some sass variables depending on env variable.

my theme1.scss file

@if 'theme1' == process.env.THEME {
$color-secondary: #eee;
$color-primary: #ff0;

How can i send my env to the broccoli build process

and how can I access the env variables in sass script?

Answer Source

after tracing the code back thru the ember-cli-sass module to the base broccoli-sass code i found that we can pass functions to sass in sassOptions.

var sass = require('node-sass');
var app = new EmberApp({

  sassOptions: {
    functions: {
      variable: function () {
        return new sass.types.String(process.env.VARIABLE);

and then we can use it as a method in sassScript

@if variable() == 'foo' {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download