A Babel plugin that minifies gql template literals by removing whitespace, comments, and unnecessary characters from GraphQL queries defined inline with the gql tag. Compatible with Babel 6 and 7 (used in many projects still). Current stable version 1.1.1, no active development seen since 2019. Uses simple string manipulation (full name removal) rather than parsing with graphql-js, making it lightweight and fast. This approach avoids bundle size increases from AST pre-compilation while still reducing payload. Alternative to graphql-tag/loader for those who inline queries.
npm install babel-plugin-transform-minify-gql-template-literalsVerified import paths — ran on the pinned version, not inferred.
Shows configuration as Babel plugin and example of minification effect on a simple gql template literal.
Place plugin first in plugins array.
Use gql tag exactly, or fork plugin to support other tags.
Ensure GraphQL queries are valid before minification.
Consider alternative plugins or contribute updates.
Run npm install --save-dev babel-plugin-transform-minify-gql-template-literals or yarn add --dev babel-plugin-transform-minify-gql-template-literals
Add import gql from 'graphql-tag' at top of file.
Use plugins: ['babel-plugin-transform-minify-gql-template-literals'] in config object.