Created
August 29, 2016 13:58
-
-
Save eliranmal/f13c822cec47735baea36cfedac48f7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this is a configuration file for grunt-string-replace plugin | |
| // todo - turn this into a proper grunt plugin of its own | |
| module.exports = function (grunt) { | |
| var config = { | |
| sass: {} | |
| }, | |
| cdnRoot = grunt.option('cdnRoot'); | |
| function getSassConfig() { | |
| var varName, varValue, | |
| configReplacements = [], | |
| replacementVariables = { | |
| 'cdn-root': cdnRoot | |
| }; | |
| for (varName in replacementVariables) { | |
| varValue = replacementVariables[varName]; | |
| configReplacements.push({ | |
| pattern: new RegExp('\\$' + varName + ':\\s*["\'].*["\'].*;', 'g'), | |
| replacement: '$' + varName + ': "' + varValue + '";' | |
| }); | |
| } | |
| return { | |
| files: { | |
| '../assets/scss/_global-vars.scss': '../assets/scss/_global-vars.scss' | |
| }, | |
| options: { | |
| replacements: configReplacements | |
| } | |
| }; | |
| } | |
| if (cdnRoot) { | |
| config.sass = getSassConfig(); | |
| } | |
| return config; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment