Created
February 8, 2019 15:15
-
-
Save alberto-chiesa/b21500885a22586767a36a7e8f10beb6 to your computer and use it in GitHub Desktop.
Export scss file with variables into TypeScript
This file contains 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
var scssToJson = require('scss-to-json'); | |
var path = require('path'); | |
var fs = require('fs'); | |
var BasePath = 'projects/myProj/src'; | |
var scssInputPath = path.resolve(__dirname, svCoreBasePath, 'styles', '_variables.scss'); | |
var tsOutputPath = path.resolve(__dirname, svCoreBasePath, 'app', 'css-variables.ts'); | |
var variables = scssToJson(scssInputPath); | |
var fileContent = | |
'// tslint:disable:quotemark\nexport const CSS_VARIABLES = ' + JSON.stringify(variables, null, ' ') + ';\n'; | |
fs.writeFileSync(tsOutputPath, fileContent, { | |
encoding: 'utf8', | |
flag: 'w' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment