drupal-vite
Version:
Vite plugin for Drupal integration
72 lines (71 loc) • 1.96 kB
TypeScript
import { type Plugin } from "vite";
import type { DrupalPluginOptions } from "./types";
export type { DrupalDecoupledConfig } from "./types";
/**
* Creates a Vite plugin for Drupal integration
*
* @description
* This plugin provides seamless integration between Vite and Drupal by:
* - Setting up authentication with Drupal using OAuth
* - Configuring a GraphQL client for Drupal queries
* - Managing environment variables and configuration
* - Exposing helper functions for auth and GraphQL operations
*
* @example
* ```ts
* // vite.config.ts
* import { defineConfig } from 'vite';
* import { drupal } from 'drupal-vite';
*
* export default defineConfig({
* plugins: [
* drupal()
* ]
* });
* ```
*
* @example
* ```ts
* // vite.config.ts with direct configuration
* import { defineConfig } from 'vite';
* import { drupal } from 'drupal-vite';
*
* export default defineConfig({
* plugins: [
* drupal({
* drupalUrl: 'https://your-drupal-site.com',
* simple_oauth: {
* clientID: 'your-client-id',
* clientSecret: 'your-client-secret'
* },
* graphql: {
* endpoint: '/graphql'
* }
* })
* ]
* });
* ```
*
* @example
* ```ts
* // vite.config.ts with environment variable references
* import { defineConfig } from 'vite';
* import { drupal } from 'drupal-vite';
*
* export default defineConfig({
* plugins: [
* drupal({
* drupalUrl: 'DRUPAL_URL', // Will use process.env.DRUPAL_URL
* simple_oauth: {
* clientID: 'DRUPAL_CLIENT_ID', // Will use process.env.DRUPAL_CLIENT_ID
* clientSecret: 'DRUPAL_CLIENT_SECRET' // Will use process.env.DRUPAL_CLIENT_SECRET
* }
* })
* ]
* });
* ```
*
* @param {DrupalPluginOptions} options - Configuration options for the plugin
* @returns {Plugin} A Vite plugin instance
*/
export declare function drupal(options?: DrupalPluginOptions): Plugin;