Specify SASS variable to compile with Grunt-Contrib-Sass

Is it possible to specify a variable in SASS from GruntFile.js before compiling with Grunt-contrib-sass?

For example, if absolute paths were needed in CSS, the path could be determined by a Gruntfile based on a dev assembly or deployment assembly.

For those familiar with LESS ( https://github.com/gruntjs/grunt-contrib-less ), this will be SASS, equivalent to LESS ' modifyVars.

GruntFile Example

...
sass: {
    deploy: {
        vars: {
           absolute: "http://www.example.com/"
        }
    },
    dev: {
        vars: {
            absolute: "/local_path/"
        }
    }
}
...

SASS Example

.element {
    background-image: url("#{absolute}image.jpg");
}
+4
source share
1 answer

Grunt Sass. . grunt SASS , . Compass , , , SASS, , . SASS/Coffeescript .

Grunt .

sass: {
    deploy: {
        options: {
            environment: "production"
        }
    },
    dev: {
        options: {
            environment: "development"
        }
    }
}
+2

All Articles