Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing variable to SASS with Grunt

Tags:

sass

gruntjs

I want to be able to "@import" a file with SASS depending on a Grunt parameter.

With grunt I want to:

grunt someTask --skinName=yellow

Inside app.scss I want to somehow use this parameter:

@import "$skinName";

Some context...

This skinName.scss contains a lot of SASS variables with color codes so that I can easily change colors all over the app. I Should be included before all my SASS @imports.

like image 721
Temega Avatar asked May 13 '14 09:05

Temega


1 Answers

You could solve this with another scss file that is written by grunt during the build process:

grunt.registerTask('skin', function () {
    grunt.file.write('skin.scss', '@import "' + grunt.option('skinName') + '";');
});

Then simply import the skin.scss in your app.scss.

like image 90
jgillich Avatar answered Sep 23 '22 10:09

jgillich