Giter VIP home page Giter VIP logo

Comments (8)

jgranstrom avatar jgranstrom commented on July 28, 2024

@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.

adamgruber avatar adamgruber commented on July 28, 2024

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.

jeffijoe avatar jeffijoe commented on July 28, 2024

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.

adamgruber avatar adamgruber commented on July 28, 2024

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.

jeffijoe avatar jeffijoe commented on July 28, 2024

@adamgruber nice! Is it an intermediary loader?

from sass-extract.

adamgruber avatar adamgruber commented on July 28, 2024

@jeffijoe It's standalone right now, not a loader.

from sass-extract.

jgranstrom avatar jgranstrom commented on July 28, 2024

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.

adamgruber avatar adamgruber commented on July 28, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.