1.1.2 • Published 12 months ago

vite-plugin-jsonx v1.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

vite-plugin-jsonx

This is a Vite plugin that enables you to import JSONC and JSON5 files as modules in your Vite project.

Features

  • Import JSON5 files as modules
  • Import JSONC files as modules
  • Customizable parse options for both JSON5 and JSONC files

Installation

You can install the plugin using npm:

npm install vite-plugin-jsonx --save-dev

Or you can use yarn:

yarn add vite-plugin-jsonx --dev

Usage

To use this plugin, first add it to your vite.config.js or vite.config.ts:

import { jsonX } from 'vite-plugin-jsonx';

export default {
  plugins: [
    jsonX()
  ]
}

or with custom options:

export default {
  plugins: [
    jsonX({
      json5ParserOptions // optional, custom parser options for json5
      jsoncParserOptions // optional, custom parser options for jsonc
    })
  ]
}

Add the following to your env.d.ts file:

/// <reference types="vite-plugin-jsonx/client" />

With this setup, you can now import JSONC and JSON5 files in your application:

import datac from './data.jsonc';
import data5 from './data.json5';

Options

This plugin supports the following options:

  • jsoncParserOptions: An optional object with custom parsing options for JSONC files. For more information, visit the documentation.
  • json5ParserOptions: An optional object with custom parsing options for JSON5 files. For more information, visit the documentation.
1.1.2

12 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.0

12 months ago