kristerkari / react-native-sass-transformer

Use Sass to style your React Native apps.
MIT License
219 stars 19 forks source link

Add Sass options #15

Closed TheButchersBoy closed 5 years ago

TheButchersBoy commented 5 years ago

Add sassOptions to Sass transformer - Issue: https://github.com/kristerkari/react-native-sass-transformer/issues/2

Example of transformer.js

var upstreamTransformer = require("metro/src/reactNativeTransformer");
var sassTransformer = require("react-native-sass-transformer");

module.exports.transform = function({ src, filename, options }) {
  if (filename.endsWith(".scss") || filename.endsWith(".sass")) {
    options.sassOptions = {
      functions: {
        "JS($value)": value => {
          return value;
        }
      }
    };
    let transformed = sassTransformer.transform({ src, filename, options });
    return transformed
  }
  return upstreamTransformer.transform({ src, filename, options });
};
kristerkari commented 5 years ago

Thanks! I have been postponing this and hoping that React Native would add a way to pass custom options to the transformer.

I guess it's best to add this option to the transformer as there is now other way of doing it currently.

kristerkari commented 5 years ago

Sorry that it took a while for me to review this. I wanted to test properly that it works the way that I designed it to work. :)

I will release a new version soon 👍

kristerkari commented 5 years ago

Thanks a lot! These changes are included in v1.3.0