Vite plugin for soda-gql
npm install @soda-gql/vite-pluginVite plugin for soda-gql. Transforms soda-gql DSL to runtime calls during development and build.
- Zero-config setup - Works out of the box with soda-gql config
- HMR support - Hot module replacement for GraphQL operations
- Fast rebuilds - Incremental artifact updates
``bash`
npm install @soda-gql/vite-pluginor
bun add @soda-gql/vite-plugin
Add the plugin to your Vite config:
`typescript
// vite.config.ts
import { defineConfig } from "vite";
import { sodaGqlPlugin } from "@soda-gql/vite-plugin";
export default defineConfig({
plugins: [sodaGqlPlugin()],
});
`
The plugin automatically loads configuration from soda-gql.config.ts.
`typescript
sodaGqlPlugin({
// Use a specific config file
configPath: "./custom-config.ts",
// Filter which files to transform
include: ["src/*/.ts"],
exclude: ["*/.test.ts"],
});
`
1. Build phase - The plugin uses @soda-gql/builder to analyze source files and generate artifacts@soda-gql/babel
2. Transform phase - Uses to replace gql.default() calls with gqlRuntime.getOperation() callsexport {};` in the bundle
3. Watch mode - Automatically rebuilds artifacts when GraphQL files change
4. Internal module stubbing - graphql-system and inject modules are stubbed with
- Vite 5.x or 6.x
- Node.js >= 18
- @soda-gql/webpack-plugin - Webpack integration
- @soda-gql/metro-plugin - React Native/Expo integration
- @soda-gql/babel - Babel transformer and plugin
MIT