0.3.2 • Published 7 years ago
babel-plugin-inline-json-import v0.3.2
babel-plugin-inline-json-import
A babel pre-processor that inlines all imports of JSON files straight into your JavaScript files.
Example
Given the following JSON file:
{
"foo": "bar"
}The plugin will transform the following statement:
import json from './path/to/file.json';or
to:
const json = { foo: "bar" };Simple as that! Both require and import are supported.
Installation
Install the plugin through npm, you will also need babel installed for
obvious reasons:
$ npm install --save-dev babel-plugin-inline-json-importAdd babel-plugin-inline-json-import to the list of plugins. If you are using a
.babelrc file, the file should have an entry that looks like this:
{
"plugins": [
["inline-json-import", {}]
]
}Usage
This should work straight out of the box without any configuration.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request =)
License
This project is licensed under the MIT License - see the LICENSE file for details
