https://github.com/kristerkari/babel-plugin-react-native-platform-specific-extensions
Allow react-native platform specific extensions to be used for other file types than Javascript.
https://github.com/kristerkari/babel-plugin-react-native-platform-specific-extensions
babel babel-plugin extensions imports platform-specific react-native
Last synced: 19 days ago
JSON representation
Allow react-native platform specific extensions to be used for other file types than Javascript.
- Host: GitHub
- URL: https://github.com/kristerkari/babel-plugin-react-native-platform-specific-extensions
- Owner: kristerkari
- License: mit
- Created: 2018-01-09T11:22:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T00:05:41.000Z (about 5 years ago)
- Last Synced: 2025-06-25T19:02:40.708Z (19 days ago)
- Topics: babel, babel-plugin, extensions, imports, platform-specific, react-native
- Language: JavaScript
- Size: 2.4 MB
- Stars: 13
- Watchers: 2
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-react-native-platform-specific-extensions
[](https://www.npmjs.org/package/babel-plugin-react-native-platform-specific-extensions)
[](https://travis-ci.org/kristerkari/babel-plugin-react-native-platform-specific-extensions)
[](https://coveralls.io/github/kristerkari/babel-plugin-react-native-platform-specific-extensions?branch=master)
[](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)
[](https://greenkeeper.io/)Allow [react-native platform specific extensions](https://facebook.github.io/react-native/docs/platform-specific-code.html#platform-specific-extensions) to be used for other file types than Javascript.
Example:
`import styles from "./styles.css";`
* `styles.android.css` <- Android only
* `styles.ios.css` <- iOS only
* `styles.native.css` <- Both Android and iOS
* `styles.css` <- Default. Android, iOS and Web## Usage
### Step 1: Install
```sh
yarn add --dev babel-plugin-react-native-platform-specific-extensions
```or
```sh
npm install --save-dev babel-plugin-react-native-platform-specific-extensions
```### Step 2: Configure `.babelrc`
You must give one or more file extensions inside an array in the plugin options.
```
{
"presets": [
"react-native"
],
"plugins": [
["react-native-platform-specific-extensions", {
"extensions": ["css", "scss", "sass"],
}]
]
}
```## TODO
* Support `require`.