Registry / devops / astro-id-minifier

astro-id-minifier

JSON →
library0.0.3jsnpmunverified

An Astro integration plugin that minifies Astro's custom data attributes (data-astro-cid-*) used for style scoping, reducing HTML and CSS file sizes by replacing long attribute names with shorter alternatives. Current version is 0.0.3. It provides two modes: 'prefix' which produces valid data attributes (e.g., data-0), and 'maximum' which uses bare base-36 numbers (e.g., a). Unlike manual find-and-replace, this plugin automatically handles the mapping between original and minified attributes across all HTML and CSS files. Note: only works with static exports; SSR is not supported.

npm install astro-id-minifier
INSTALL
IMPORT
SIG · ASTRO-ID-MINIFIER
A
astro-id-minifier
devopsjavascriptv0.0.3
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.

minifyId
import minifyId from 'astro-id-minifier'
import { minifyId } from 'astro-id-minifier'
Default export; named import will cause undefined.
Astro ID Minifier (via default import)
const minifyId = require('astro-id-minifier')
const { minifyId } = require('astro-id-minifier')
CommonJS require works, but destructuring fails because it's a default export.
Type imports (if needed)
import type { MinifierOptions } from 'astro-id-minifier'
The package exports types for options; use import type to avoid runtime overhead.

Installs and configures the Astro Id Minifier plugin with prefix mode and an exclude list, showing integration setup.

// astro.config.mjs import { defineConfig } from 'astro/config'; import minifyId from 'astro-id-minifier'; export default defineConfig({ integrations: [minifyId({ mode: 'prefix', exclude: ['data-custom'] })], });
Debug
Known issues
gotchaPlugin only works with static exports (SSG). In SSR mode, it does nothing.
fix
Ensure your Astro project uses output: 'static'.
affects: >=0.0.0
gotchaIn 'maximum' mode, attribute names become non-standard (e.g., 'a'), which will cause W3C validation to fail.
fix
Use 'prefix' mode for valid HTML attributes.
affects: >=0.0.0
gotchaIf you have custom attributes that collide with the minified names, they will be incorrectly replaced.
fix
Use the 'exclude' option to list custom attributes that should be skipped.
affects: >=0.0.0
breakingVersion 0.x may have breaking changes between minor versions; no stable API guarantee yet.
fix
Lock your version and review changelog before upgrading.
affects: >=0.0.0 <=0.0.3
Errors
Common errors & fixes
import { minifyId } from 'astro-id-minifier' returns undefined
Named import used for a default export.
fix
Use: import minifyId from 'astro-id-minifier'
Module 'astro-id-minifier' has no exported member 'MinifyOptions'
Typo: expected 'MinifierOptions' instead of 'MinifyOptions'.
fix
Use: import type { MinifierOptions } from 'astro-id-minifier'
Error: The plugin 'astro-id-minifier' is not compatible with the current Astro version
Package version mismatch; requires Astro 2.x or 3.x?
fix
Check peer dependencies; upgrade/downgrade Astro accordingly.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
astro-id-minifier — npm install astro-id-minifier · libregistry