Inlines JSON file imports straight into JS code
npm install babel-plugin-inline-json-import
A babel pre-processor that inlines all imports of JSON files straight into your
JavaScript files.
Given the following JSON file:
``json`
{
"foo": "bar"
}
The plugin will transform the following statement:
`js`
import json from './path/to/file.json';
or
to:
`js`
const json = { foo: "bar" };
Simple as that! Both require and import are supported.
Install the plugin through npm, you will also need babel installed for
obvious reasons:
`sh`
$ npm install --save-dev babel-plugin-inline-json-import
Add 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:
`json`
{
"plugins": [
["inline-json-import", {}]
]
}
This should work straight out of the box without any configuration.
3. Commit your changes: git commit -am 'Add some feature'
4. Push to the branch: git push origin my-new-feature`