babel-plugin-rn-platform-specific-extensions
Allow react-native platform specific extensions to be used for other file types than Javascript.
Last updated 5 years ago by shinken008 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-rn-platform-specific-extensions 
SYNC missed versions from official npm registry.

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',
        }
      ],
    }]
  ]
}

Current Tags

  • 1.1.1                                ...           latest (5 years ago)

10 Versions

  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 10
Dependencies (2)
Dev Dependencies (17)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |