Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rollup/rollup-plugin-json
This module has moved and is now available at @rollup/plugin-json / https://github.com/rollup/plugins/blob/master/packages/json
https://github.com/rollup/rollup-plugin-json
Last synced: 18 days ago
JSON representation
This module has moved and is now available at @rollup/plugin-json / https://github.com/rollup/plugins/blob/master/packages/json
- Host: GitHub
- URL: https://github.com/rollup/rollup-plugin-json
- Owner: rollup
- Archived: true
- Created: 2015-10-24T17:04:42.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-04T16:23:12.000Z (over 3 years ago)
- Last Synced: 2024-09-07T23:08:14.483Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 229 KB
- Stars: 126
- Watchers: 15
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Moved
This module has moved and is now available at [@rollup/plugin-json](https://github.com/rollup/plugins). Please update your dependencies. This repository is no longer maintained.
# rollup-plugin-json
Convert .json files to ES6 modules:
```js
// import a single property from a JSON file,
// discarding the rest
import { version } from './package.json';
console.log( `running version ${version}` );// import the whole file as an object
import pkg from './package.json';
console.log( `running version ${pkg.version}` );
```## Installation
```bash
npm install --save-dev rollup-plugin-json
```## Usage
```js
// rollup.config.js
import json from 'rollup-plugin-json';export default {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: 'iife'
},plugins: [
json({
// All JSON files will be parsed by default,
// but you can also specifically include/exclude files
include: 'node_modules/**',
exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false// specify indentation for the generated default export —
// defaults to '\t'
indent: ' ',// ignores indent and generates the smallest code
compact: true, // Default: false// generate a named export for every property of the JSON object
namedExports: true // Default: true
})
]
};
```## License
MIT