0.2.0 • Published 12 months ago

unplugin-graphql v0.2.0

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

unplugin-graphql

NPM version

šŸ£ A universal bundler plugin which Converts .gql/.graphql(s) files to ES6 modules.

Install

npm i unplugin-graphql
// vite.config.ts
import UnpluginGraphql from 'unplugin-graphql/vite'

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

Example: playground/

// rollup.config.js
import UnpluginGraphql from 'unplugin-graphql/rollup'

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

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

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

This module works for both Nuxt 2 and Nuxt Vite

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

// esbuild.config.js
import { build } from 'esbuild'
import UnpluginGraphql from 'unplugin-graphql/esbuild'

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

Usage

Options

For all options please refer to docs.

This plugin accepts all @rollup/plugin-graphql options.