Registry / devops / minify-graphql-loader

minify-graphql-loader

JSON →
library1.0.2jsnpmunverified

A webpack loader that minifies GraphQL queries, mutations and fragments by stripping whitespace and reducing query length before bundling. Version 1.0.2 is the latest stable release. The loader must be chained after graphql-tag/loader (or similar) to first transform .gql/.graphql files into JavaScript, then minify them. Key differentiator: reduces bundle size by an average of ~17.5% per query. Targeted at Node.js >=10.0.0. The project is relatively stable with a small maintenance footprint.

npm install minify-graphql-loader
INSTALL
IMPORT
SIG · MINIFY-GRAPHQL-LOA
M
minify-graphql-loader
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

minify-graphql-loader
module.exports = { module: { rules: [ { test: /\.(graphql|gql)$/, use: ['graphql-tag/loader', 'minify-graphql-loader'] } ] } }
module.exports = { module: { rules: [ { test: /\.(graphql|gql)$/, use: ['minify-graphql-loader', 'graphql-tag/loader'] } ] } }
Order matters: minify-graphql-loader must be the last loader in the use array (i.e., applied after graphql-tag/loader).
minify-graphql-loader
import loader from 'minify-graphql-loader'
const loader = require('minify-graphql-loader')
This is a webpack loader; it is not intended for direct import in application code. The loader is used in webpack config, not in source files.
graphql-tag/loader
use: ['graphql-tag/loader', 'minify-graphql-loader']
use: ['minify-graphql-loader', 'graphql-tag/loader']
graphql-tag/loader must come first because it transforms .graphql files into JavaScript. minify-graphql-loader then minifies the resulting code.

Webpack configuration using minify-graphql-loader in chain with graphql-tag/loader to minify GraphQL imports.

// webpack.config.js const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, module: { rules: [ { test: /\.(graphql|gql)$/, exclude: /node_modules/, use: [ 'graphql-tag/loader', 'minify-graphql-loader' ] } ] } };
Debug
Known issues
gotchaLoader order is critical: minify-graphql-loader must be last in the loaders chain.
fix
Ensure use array has 'graphql-tag/loader' first, then 'minify-graphql-loader'.
affects: >=1.0.0
gotchaOnly supports webpack and requires a GraphQL loader to precede it; does not work standalone.
fix
Always pair with a GraphQL loader like graphql-tag/loader.
affects: >=1.0.0
gotchaDoes not provide TypeScript type definitions.
fix
Install @types/graphql or use inline type declarations if needed.
affects: >=1.0.0
gotchaVersion 1.0.2 is the latest but may not be actively maintained; no updates since 2020.
fix
Consider forking or using alternative like babel-plugin-minify-graphql.
affects: 1.0.2
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:6) You may need an appropriate loader to handle this file type.
Missing graphql-tag/loader before minify-graphql-loader or no GraphQL loader configured.
fix
Add 'graphql-tag/loader' before 'minify-graphql-loader' in webpack rules.
Error: Could not load loader: minify-graphql-loader
Package not installed or not listed in devDependencies.
fix
Run 'npm install --save-dev minify-graphql-loader' or 'yarn add --dev minify-graphql-loader'.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
minify-graphql-loader — npm install minify-graphql-loader · libregistry