1.1.2 • Published 4 months ago

vite-plugin-json5 v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

🔌 Vite JSON5 (and JSONC) plugin

Plugin for allowing .json5 and .jsonc files to be loaded.

!NOTE This plugin is merely just a wrapper using the json5 package. So all the credits for the parsing goes out to the collaborators of that repository! I just made a plugin that allows files to be parsed using their package.

📦 Installation in 3 easy steps:

1. Install the package into to your project

# PNPM:
pnpm add -D vite-plugin-json5

# Yarn:
yarn add -D vite-plugin-json5

# NPM:
npm install -D vite-plugin-json5

2. Add it to your vite config

// vite.config.js

import json5Plugin from 'vite-plugin-json5'

export default defineConfig({
  json5Plugin()
})

3. That's it 🎉

You are now able to import files with the .jsonc and .json5 extensions! These will be parsed by the json5 package and turned into a regular js that the app will be able to read and not get confused by.

Options ⚙️

This plugin accepts the same options as the default JSON parser:

interface Json5Options {
    /**
     * Generate a named export for every property of the JSON object
     * @default true
     */
    namedExports?: boolean;
    /**
     * Generate performant output as JSON.parse("stringified").
     * Enabling this will disable namedExports.
     * @default false
     */
    stringify?: boolean;
}

Extra 🍕

1.1.2

4 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago