-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing JSON #1585
Comments
As a Compass user, i would do it from the If you're not using Compass, you could probably do the same by requiring a Ruby file via the |
There are Sass extensions that provide this. It is not something that we will be putting into the Sass core functions. https://github.com/HugoGiraudel/SassyJSON |
@chriseppstein before I open a new bug for this, please would you share the reasons for not putting this into the Sass core functionality? The alternatives you provided are totally not suitable for any serious project (in fairness to you, you posted these over 3 years ago). Today a better alternative would be https://www.npmjs.com/package/node-sass-json-importer, but even still this doesn't work properly (you cannot just import valid JSON, you must double quote strings, which makes it largely unsuitable) but I digress. The ability to natively import json into a sass file would be immensely useful, and for peace of mind it would be great to have a proper reason why you won't consider this. Requiring third party extensions to follow best practices is something I think we should be striving to avoid. Without the ability to import JSON, Sass will eventually die in favour of CSS in JS. |
I'll just leave it here |
@ArmorDarks I'm unfortunately too dumb to really understand what that is, other than, presumably, a gate to be able to import JSON files without requiring a third party tool? I will be sure to read into properly, though, so thanks. |
You can define a function, which will read in Node environment JSON data from whatever you want and pass it to the Sass. Here is example how to pass a function within Grunt, and the function itself, which retrieves data from Grunt (but you can read there external JSON). |
Oh ok, that sounds very interesting, thanks for sharing the resources. |
Can I import variables defined in a JSON file? This is great for DRY purposes, as often I need to share variables with other languages (like javascript). I know there are ad-hoc ways of achieving this but I guess what I'm asking is - should it not be built in?
The text was updated successfully, but these errors were encountered: