A Babel plugin (v1.3.3, latest stable) that removes unnecessary whitespace from GraphQL queries embedded in template literals during build. It compresses queries tagged with a configurable tag (default `gql`) or marked with a block comment like `/* GraphQL */`. The plugin uses `graphql-query-compress` under the hood and integrates seamlessly with Babel's env configuration to apply only in production. Unlike manual minification, it automates compression as part of the transpilation pipeline, supporting both tag and comment-based detection.
npm install babel-plugin-transform-compress-graphqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows configuration in .babelrc for production-only compression and a typical input/output example using the gql tag.
Ensure tagged literals are template literals (backticks) or use the gql tag.
Avoid using `tagFunction` unless confirmed; default empty string removes the tag.
Always use template literals with backticks for GraphQL queries.
Set `removeComments: true` (default) to strip comments from output.
Run: npm install --save-dev graphql-query-compress
Define a dummy tag: const gql = (strings) => strings.raw[0]; or import from a library like graphql-tag.
Wrap options in an extra array: ["transform-compress-graphql", { ... }] inside the plugins array.