Package Exports
- react-native-stylus-transformer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-stylus-transformer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-native-stylus-transformer
Load Stylus files to react native style objects.
This transformer can be used together with React Native CSS modules.
Usage
Step 1: Install
yarn add --dev react-native-stylus-transformer stylus
Step 2: Configure the react native packager
Add this to your rn-cli.config.js
(make one if you don't have one already):
module.exports = {
getTransformModulePath() {
return require.resolve("react-native-stylus-transformer");
},
getSourceExts() {
return ["styl"];
}
};
How does it work?
Your App.styl
file might look like this:
.myClass {
color: blue;
}
.myOtherClass {
color: red;
}
When you import your stylesheet:
import styles from "./App.styl";
Your imported styles will look like this:
var styles = {
myClass: {
color: "blue"
},
myOtherClass: {
color: "red"
}
};
You can then use that style object with an element:
<MyElement style={styles.myClass} />