4.0.0 • Published 5 years ago

rollup-plugin-json v4.0.0

Weekly downloads
178,735
License
MIT
Repository
github
Last release
5 years ago

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

@admin-bro/coremarigold-build@bunchee/buncheecf-storybookcb-react-notificationstsdx-extra@huozhi/burritoqinshixixing-rollupadmin-bro-jzreact-form-typescriptnotiontheory-basic-buildcloud-archive-s3video-clip-ljskingsun-ui-expandvue-waterfall-jy@codewitchbella/microbundletakla-builder-rollupmethods-to-expand@thebespokepixel/cordialfather-build-mbptestchangzhn-jsonptestemoreact-tstinboxblazedocsuz-claim-componentsazure-functions-bundlexania-cli@infinitebrahmanuniverse/nolb-rollup-plugin-jpackage-scripts@everything-registry/sub-chunk-2680react-styled-ui-componentsautographql@andriepu/rollup-plugin-yamllobotlocalservicejsmonitor-sdk-demonasdkng-packagr-bknng-packagr-devnick-scriptsnnms-climock2filemoe-scriptsmarkdown-it-esmmlin-scriptsnature-clinature6-clinbugs-component-tools-testndv-scriptsnforgetnewchain-web3-utilsnewbot-clinex-dom-utilsmyfirst-test-norepeatnamemyccqnetlify-cms-widget-material-iconsmacro_toolmacro_utilslux-frameworklux-framework-llcmake_module_distmerge-umi-mock-datamicrowebchatmetalboxnodify-corenpm-pnpnpm-preset-videojsnaapimax-js-bundlerlouison-react-modalmediumpostscard@valy/tsd@transformer-cli/editor@urkellabs/ucl@travlrcomlabs/theme-generator@unified-tv/rollup-config@twinsvicki/giscomponent@tunnckocore/rollup-config@xme/cli-servicealan@xsyx/hanzo-cliada-scriptsaltu-components@zerollup/rollup-preset-ts@vope/template-node@weddingshoppe/lux@zine56/test-module-npm@voila/module@voila/website@wangly19/tool-kit@wtg/scripts@workspace-builder/rollup-cjs@workspace-builder/rollup-umd@wvw/preppy@youssefbellarbia/react-notifications-menuamber-tools@yproximite/yprox-cli@yunyan/hongyunavtrbedrock-development-vue
4.0.0

5 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.3.1

6 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.0

8 years ago