adamgruber/sass-extract-js

Suggestions for Refactor

Closed this issue · 2 comments

I had a use case which called for pulling in SASS variables from a design system to populate the "knob" options in a storybook app for a component library I authored. After trying out sass-extract I started writing a parser for the SASS AST when I stumbled across this library. After trying out the lib a few things jumped out at me.

It seems strange to bundle this as a webpack plugin since it has a hard dependency on sass-extract not sass-extract-loader. If this was bundled to only export transformStyles it might provide more utility to the community.

Also, the remapping of map keys to camelCase is lossy and prevents keys from being used in meaningful way such as populating the dropdown "knob" options for component libraries using storybook.

Hey @hansoksendahl , thanks for the feedback!

It seems strange to bundle this as a webpack plugin since it has a hard dependency on sass-extract not sass-extract-loader.

To be clear, this is a plugin for sass-extract NOT webpack.

If this was bundled to only export transformStyles it might provide more utility to the community.

I would consider updating the package to export this function separately. Then you could do

import transformStyles from 'sass-extract-js/transformStyles';

I've created #2 to track this.

Also, the remapping of map keys to camelCase is lossy and prevents keys from being used in meaningful way...

I debated this decision quite a bit and ended up forcing the change to camelCase because it fit the use-cases I was targeting. However, I can see value in adding an option to skip the camel casing. Will track it via #3.

0.2.0 published to address these issues