Comments (8)
@adamgruber thank you for your feedback!
I understand your point and I agree that it can be useful to transform the result into other formats based on the use case. The current structure is very generic for the purpose of being able to use it in many different ways without having to parse strings and so on. The idea was that you just as you did can use that result to transform it in any way you need that fits your use case.
I am thinking about adding a feature to serialize the result where you can pass in transformation functions similar to what you have in your gist, and that might include a few bundled transformations for common formats like the one you are mentioning, which would be to just generate css-like strings from the variables. These would be css-like because it might not be valid css due to the nature of sass variables, they can be fairly arbitrary values. This feature will likely be included in a near future release. This will be similar to what is being done in #4 and will likely be released with that.
from sass-extract.
Thanks for the response. I get why you built this as you did, makes total sense. I think a feature to serialize the result would be an awesome addition.
from sass-extract.
A serialize
/ compact
option for the loader would be awesome.
I completely understand why the current output is as verbose as it is, it certainly has it's uses, but an option for compact output would be awesome. Not only does it make general consumption easier, but it also makes your bundle size smaller.
Looking forward to seeing this implemented - great work on this library @jgranstrom!
from sass-extract.
I started to work on a library using my gist from above. It serializes the sass to JS. Hope to release it within the next few days.
from sass-extract.
@adamgruber nice! Is it an intermediary loader?
from sass-extract.
@jeffijoe It's standalone right now, not a loader.
from sass-extract.
The new plugin support from version 1.0.0 comes with a bundled minimal
plugin that will give you a proper serialized variant of the output with support for all kinds of nested data types.
This can be used with the loader from version 1.0.0 and sass-extract from version 1.0.1.
npm install [email protected] [email protected]
const style = require('sass-extract-loader?{"plugins":["minimal"]}!./theme.scss');
/* theme ==>
{
$primary: 'rgba(255, 239, 213)',
$baseMargin: '4px',
$baseBorder: '1px solid black'
}
*/
Go ahead and try it and see if this works in the way you need it to. You can also have a look at the bundled plugins and see if one or a combination of those is what you are looking for, or use it as a reference to create your own plugin for your specific case.
from sass-extract.
@jgranstrom Thanks for your hard work on this package. The new version is awesome and fixes all the issues I saw. Also the plugin architecture is really nice. I took the project I was working on and converted it to a plugin, sass-extract-js. I think it works much better as a plugin instead of standalone.
from sass-extract.
Related Issues (20)
- Support custom node-sass `importer` compileOption.
- Compact should not drop unit / new plugin needed HOT 3
- Parsing error while parsing Bulma SASS HOT 3
- DeprecationWarning: Module Chunks HOT 2
- Add a built in plugin for flexible transformation of output format HOT 1
- Raw css imports are not supported HOT 1
- Parse error in Bootstrap v4.1 HOT 1
- Prototype Pollution vulnerability of dependency HOT 3
- Function references assigned to variables throw errors HOT 1
- Importers - callback vs. Promise
- Unable to parse variables which contain a forward-slash `/`
- Render fails for SCSS file encoded in UTF8-BOM HOT 1
- When calling the `findImportedPath` the `url` should be normalized to prevent issues on Windows
- Support for Dart Sass (possibility for using custom implementation) HOT 13
- Include doc comments HOT 2
- Sass plugin usage HOT 2
- Update node-sass peer dependency version? HOT 3
- Enable hex values to be capitalized HOT 1
- Look into nested map regression HOT 2
- Error when extracting variables with values containing calc function HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sass-extract.