Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 8 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 (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T00:05:41.000Z (over 4 years ago)
- Last Synced: 2024-09-19T06:16:20.329Z (about 2 months ago)
- Topics: babel, babel-plugin, extensions, imports, platform-specific, react-native
- Language: JavaScript
- Size: 2.4 MB
- Stars: 14
- Watchers: 3
- 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
[![NPM version](http://img.shields.io/npm/v/babel-plugin-react-native-platform-specific-extensions.svg)](https://www.npmjs.org/package/babel-plugin-react-native-platform-specific-extensions)
[![Build Status](https://travis-ci.org/kristerkari/babel-plugin-react-native-platform-specific-extensions.svg?branch=master)](https://travis-ci.org/kristerkari/babel-plugin-react-native-platform-specific-extensions)
[![Coverage Status](https://coveralls.io/repos/github/kristerkari/babel-plugin-react-native-platform-specific-extensions/badge.svg?branch=master)](https://coveralls.io/github/kristerkari/babel-plugin-react-native-platform-specific-extensions?branch=master)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)
[![Greenkeeper badge](https://badges.greenkeeper.io/kristerkari/babel-plugin-react-native-platform-specific-extensions.svg)](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`.