rollup-plugin-json
Convert .json files to ES6 modules:
Last updated 7 months ago by lukastaegert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rollup-plugin-json 
SYNC missed versions from official npm registry.

rollup-plugin-json

Convert .json files to ES6 modules:

// 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

npm install --save-dev rollup-plugin-json

Usage

// 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

Current Tags

  • 4.0.0                                ...           latest (7 months ago)

12 Versions

  • 4.0.0                                ...           7 months ago
  • 3.1.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.3.1                                ...           a year ago
  • 2.3.0                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 9
This Week 3,105
This Month 6,946
Last Day 168
Last Week 3,280
Last Month 13,426
Dependencies (1)
Dev Dependencies (10)
Dependents (485)

Copyright 2014 - 2017 © taobao.org |