https://github.com/csath/babel-plugin-rn-white-label
Transforms require statements for given custom extensions
https://github.com/csath/babel-plugin-rn-white-label
babel-plugin babel-plugin-rn-white-label react-native transforming-files
Last synced: about 2 months ago
JSON representation
Transforms require statements for given custom extensions
- Host: GitHub
- URL: https://github.com/csath/babel-plugin-rn-white-label
- Owner: csath
- Created: 2019-12-04T10:24:43.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T23:26:44.000Z (over 2 years ago)
- Last Synced: 2025-03-30T06:51:17.241Z (3 months ago)
- Topics: babel-plugin, babel-plugin-rn-white-label, react-native, transforming-files
- Language: JavaScript
- Homepage:
- Size: 439 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# babel-plugin-rn-white-label [](https://npmjs.com/package/babel-plugin-rn-white-label) [](https://npmjs.com/package/babel-plugin-rn-white-label)
Transforms require statements for given custom extensions:
_This plugin was originally created for [react-native-white-label](https://github.com/csath/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,

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
```to be modified
npm install --save-dev babel-plugin-rn-white-label
```
or
```
yarn add -D babel-plugin-rn-white-label
```## Usage
`babel.config.js`:
```javascript
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
['rn-white-label', {
mask: 'csa',
exts: ["png", "jpeg", "gif"]
}
]
]
};
```or
`.babelrc`:
```json
{
"plugins": [
["rn-white-label", {
"mask": "csa",
"exts": ["png", "jpeg", "gif"]
}
]
]
}
```