0.2.1 • Published 12 months ago

unplugin-json2 v0.2.1

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

unplugin-json

NPM version

šŸ£ A universal bundler plugin which Converts .json files to ES6 modules.

Install

If you just want to import the json file, you only need to use it in rollup. Other build tools have built-in support for json import.

npm i unplugin-json
// vite.config.ts
import UnpluginJson from 'unplugin-json/vite'

export default defineConfig({
  plugins: [
    UnpluginJson({ /* options */ }),
  ],
})

Example: playground/

// rollup.config.js
import UnpluginJson from 'unplugin-json/rollup'

export default {
  plugins: [
    UnpluginJson({ /* options */ }),
  ],
}

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-json/webpack')({ /* options */ })
  ]
}

// nuxt.config.js
export default defineNuxtConfig({
  modules: [
    ['unplugin-json/nuxt', { /* options */ }],
  ],
})

This module works for both Nuxt 2 and Nuxt Vite

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-json/webpack')({ /* options */ }),
    ],
  },
}

// esbuild.config.js
import { build } from 'esbuild'
import UnpluginJson from 'unplugin-json/esbuild'

build({
  plugins: [UnpluginJson()],
})

0.2.1

12 months ago