skip to Main Content

I’m trying to find a way to implement SASS in my react native project. All I found is this package react-native-sass-transformer, but it doesn’t seem to work on my end. Tried looking for other way but all I see is approach in React instead. Does anyone know another way into implementing SASS in a react native cli project? Thank you!

2

Answers


  1. I bet you’re trying to use react native sass transformer with .tsx (typescript implementation), if it’s the case, you just need to :

    //@ts-ignore
    import styles from './app.scss';
    

    And then it should work.
    You can also use: https://github.com/kristerkari/react-native-typed-sass-transformer to handle types (I didn’t tried yet, but I’ll !)

    Good luck!

    Login or Signup to reply.
  2. Are you using Expo and running it on the web? , if that’s the case, the problem you’re getting is caused because by default Expo uses webpack and not Metro, so it is required to change app.js

    {
      "expo": {
        ...,
        "packagerOpts": {
          "config": "metro.config.js",
          "sourceExts": ["ts", "tsx", "scss"] /* Typescript and scss */
        },
        "web": {
          "bundler": "metro", /* Expo Web uses webpack by default */
          ...
        },
        ...
      }
    

    more information here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search