n370 / rollup-plugin-geojson

An unofficial Rollup plugin which Converts .geojson files to ES6 modules.

Home Page:https://www.npmjs.com/package/rollup-plugin-geojson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm size libera manifesto

rollup-plugin-geojson

🍣 An unofficial Rollup plugin which Converts .geojson files to ES6 modules.

Requirements

This plugin requires an LTS Node version (v8.0.0+) and Rollup v1.20.0+.

Install

Using npm:

npm install rollup-plugin-geojson --save-dev

Usage

Create a rollup.config.js configuration file and import the plugin:

import geojson from 'rollup-plugin-geojson';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [geojson()]
};

Then call rollup either via the CLI or the API.

With an accompanying file src/index.js, the local data.geojson file would now be importable as seen below:

// src/index.js
import data from './data.geojson';
console.log(`running version ${data.features}`);

Options

compact

Type: Boolean
Default: false

If true, instructs the plugin to ignore indent and generates the smallest code.

exclude

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.

include

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.

indent

Type: String
Default: '\t'

Specifies the indentation for the generated default export.

namedExports

Type: Boolean
Default: true

If true, instructs the plugin to generate a named export for every property of the JSON object.

preferConst

Type: Boolean
Default: false

If true, instructs the plugin to declare properties as variables, using either var or const. This pertains to tree-shaking.

Meta

CONTRIBUTING

LICENSE (MIT)

About

An unofficial Rollup plugin which Converts .geojson files to ES6 modules.

https://www.npmjs.com/package/rollup-plugin-geojson

License:Other


Languages

Language:JavaScript 94.6%Language:TypeScript 5.4%