Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow platform extensions in preprocessor imports #12

Open
birkir opened this issue Aug 2, 2018 · 6 comments
Open

Allow platform extensions in preprocessor imports #12

birkir opened this issue Aug 2, 2018 · 6 comments
Assignees
Labels
Enhancement ✨ New feature or request Help wanted 🙋 Extra attention is needed

Comments

@birkir
Copy link

birkir commented Aug 2, 2018

Currently the import system for each supported preprocessor works independently, so we won't get the features from metro bundler built in.

It would be great to be able to do something like this:

// variables.ios.scss
$primary-color: blue;

// variables.android.scss
$primary-color: red;

// helloworld.scss
@include 'variables.scss';

.helloWorld {
  color: $primary-color;
}

Which would result in blue color for android and red color for ios.

It would be great to be able to use metros resolver for this, but second option would be to implement extension to each preprocessors resolver somehow.

Note: platform extensions work when importing from JavaScript, this issue is about within an css file.

@birkir birkir changed the title Allow platform extensions in preprocessors Allow platform extensions in preprocessor imports Aug 2, 2018
@kristerkari kristerkari added Enhancement ✨ New feature or request Help wanted 🙋 Extra attention is needed labels Aug 2, 2018
@kristerkari
Copy link
Owner

I think that we can add support for platform specific Sass/Less/Stylus imports to the transformers.

It would be great to have it supported by React Native's bundler, but at the same time it's probably much faster to do it for each transfomer.

@birkir
Copy link
Author

birkir commented Aug 9, 2018

Good news! With react native 57, the metro packager has been updated with support for custom config.

We should be getting closer to hooking into the resolver!

https://github.com/facebook/metro/tree/master/packages/metro-config

@kristerkari
Copy link
Owner

That's great! Looking forward to RN 57 to be released.

@kristerkari
Copy link
Owner

I've been playing around with v0.57.0-rc.2 today. I'm trying to get a good understanding of the new Metro options before the final version is released.

So far I only managed to get some errors when updating to the new config, so I need to get past that to test the new config options.

@kristerkari kristerkari self-assigned this Oct 17, 2018
@kristerkari
Copy link
Owner

I started doing this by adding support for the Sass transformer:
kristerkari/react-native-sass-transformer#16

@kristerkari
Copy link
Owner

kristerkari commented Oct 20, 2018

Status:

  • Support for Sass transformer (as of v1.3.0)
  • Support for Less transformer
  • Support for PostCSS transformer
  • Support for Stylus transformer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ New feature or request Help wanted 🙋 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants