babel-plugin-rn-white-label

2.0.0 • Public • Published

babel-plugin-rn-white-label npm npm

Transforms require statements for given custom extensions:

This plugin was originally created for react-native-white-label library.

What plugin does?

Modify require statements according to specified options.

If you have img.png asset as follows using custom extensions,

Image of Assets

and if you want to bundle different files without modifiying the code,

require('./src/img.png')

for specific configs you are running your application, pass following options to babel plugin.

{ mask: 'csa', exts: ["png", "jpeg", "gif"] }

If src directory has img.csa.png bundler will pick up it or if img.csa.png is not available it'll pick up img.png

Options

Attribute Data type Description
mask String | "" Custom extension (eg: 'csa' to pick up for abc.csa.png)
exts String Array | [] Extensions to be modified (eg: ['png', 'jpeg'])

Installation

npm install --save-dev babel-plugin-rn-white-label

or

yarn add -D babel-plugin-rn-white-label

Usage

babel.config.js:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    ['rn-white-label', { 
      mask: 'csa', 
      exts: ["png", "jpeg", "gif"]
    }
    ]
  ]
};

or

.babelrc:

{
  "plugins": [
    ["rn-white-label", {
      "mask": "csa",
      "exts": ["png", "jpeg", "gif"]
     }
    ]
  ]
}

Package Sidebar

Install

npm i babel-plugin-rn-white-label

Weekly Downloads

1

Version

2.0.0

License

ISC

Unpacked Size

138 kB

Total Files

5

Last publish

Collaborators

  • csath