1.1.1 • Published 3 years ago

babel-plugin-rn-platform-specific-extensions v1.1.1

Weekly downloads
33
License
MIT
Repository
github
Last release
3 years ago

babel-plugin-rn-platform-specific-extensions

NPM version Build Status Coverage Status PRs Welcome Greenkeeper badge

Allow react-native platform specific extensions to be used for other file types than Javascript inspired by react-native-platform-specific-extensions.

Example:

import styles from "./styles.css";

  • styles.android.css <- Android only
  • styles.ios.css <- iOS only
  • styles.native.css <- Both Android and iOS
  • styles.rn.css <- rn only
  • styles.css <- Default. Android, iOS and Web

Usage

Step 1: Install

yarn add --dev babel-plugin-rn-platform-specific-extensions

or

npm install --save-dev babel-plugin-rn-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": [
    ["rn-platform-specific-extensions", {
      // default ["os", "native", "rn"]. 'os' includes 'ios' and 'andriod'
      "platforms": ["os", "native", "rn"],
      "extensions": [".css", ".scss", ".sass"],
      // default [".tsx", ".ts", ".jsx", ".js"]. Recommand custom config, should be prioritized by language
      "omitExtensions": [".tsx", ".ts", ".jsx", ".js"],
      "include": [
        "workspaceFolder/src/external",
        {
          // especially config, modify current file path
          'node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js': 'entry path.js',
        }
      ],
    }]
  ]
}
1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.4.0

3 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago