There's no way to directly handle JSON with SCSS alone. Since you're already using Gulp, you can use an third-party tool such as eyeglass or sassport to convert JSON into a SCSS hash. Another tool available is json-sass, which you can use standalone.
If you're not using Gulp, then you would have to rely on Gem based converters but they don't seem to be actively maintained:
- https://github.com/vigetlabs/sass-json-vars
- https://github.com/HugoGiraudel/SassyJSON
There's no way to directly handle JSON with SCSS alone. Since you're already using Gulp, you can use an third-party tool such as eyeglass or sassport to convert JSON into a SCSS hash. Another tool available is json-sass, which you can use standalone.
If you're not using Gulp, then you would have to rely on Gem based converters but they don't seem to be actively maintained:
- https://github.com/vigetlabs/sass-json-vars
- https://github.com/HugoGiraudel/SassyJSON
There are at least two other solutions:
- converting JSON to SASS/SCSS variables: https://github.com/rlapoele/json-to-scss
- importing JSON into SASS/SCSS: https://github.com/Updater/node-sass-json-importer
» npm install scss-to-json
» npm install json-to-scss
» npm install @crocsx/scss-to-json
Hi a little late but have you tried this one? sass-export
It is in early version but it might help you.
Try this npm package - sass-json-export
It returns a JSON inside the output CSS file. You have the option to have the JSON returned inside a media query or a comment. This CSS file can be easily parsed to extract the JSON part into a separate JSON file.
» npm install scss-json
Hi,
I am looking for a solution that can convert SCSS (including maps, mixins, variables etc) to a JSON file as the output. It should be ideally part of the build process using any of the build tools such as webpack, grunt etc.
I tried a bunch of them - SassyJSON, sass-json-export etc. The latter works well with maps, but not mixins.
Any pointers on how we can compile SCSS to JSON?
Thanks!