@appfibre/rollup-plugin-jst

0.0.5 • Public • Published

Adapted from rollup-plugin-jst

rollup-plugin-jst

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 @appfibre/rollup-plugin-jst

Usage

// rollup.config.js
import jst from 'rollup-plugin-jst';

export default {
  input: 'src/main.js',
  output: {
    file: 'dist/bundle.js',
    format: 'iife'
  },

  plugins: [
    jst({
      // 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

Readme

Keywords

none

Package Sidebar

Install

npm i @appfibre/rollup-plugin-jst

Weekly Downloads

2

Version

0.0.5

License

GNU AFFERO GENERAL PUBLIC LICENSE

Unpacked Size

569 kB

Total Files

8

Last publish

Collaborators

  • drautenbach