{"id":21272,"library":"esbuild-plugin-svg","title":"esbuild-plugin-svg","description":"An esbuild plugin for importing SVG files as strings or custom elements, with optional SVGO minification. Version 0.1.0 is the initial release. It wraps SVGO (included) to optimize SVGs on build. Compared to alternatives like esbuild-svg-loader, it offers both string and custom element modes out of the box.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/nativew/esbuild-plugin-svg","tags":["javascript","svg","svgo","esbuild","esbuild-plugin"],"install":[{"cmd":"npm install esbuild-plugin-svg","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-svg","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-svg","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for SVG minification when minify option is true","package":"svgo","optional":true}],"imports":[{"note":"The plugin is ESM-only; CommonJS require will fail.","wrong":"const svg = require('esbuild-plugin-svg')","symbol":"default","correct":"import svg from 'esbuild-plugin-svg'"},{"note":"The module exports a default function, not a named export.","wrong":"import { svg } from 'esbuild-plugin-svg'","symbol":"svg","correct":"import svg from 'esbuild-plugin-svg'"},{"note":"Options are boolean, not strings.","wrong":"svg({ customElement: 'true', minify: 'true' })","symbol":"svg (with options)","correct":"svg({ customElement: true, minify: true })"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport svg from 'esbuild-plugin-svg';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [svg()]\n}).catch(() => process.exit(1));","lang":"javascript","description":"Shows basic usage of esbuild-plugin-svg with default options (string mode, no minification)."},"warnings":[{"fix":"Use import or set type: 'module' in your package.json.","message":"Plugin is ESM-only; cannot be used with CommonJS require().","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Pass an object with a 'plugins' array as per SVGO API.","message":"The 'minifyOptions' property expects SVGO plugin options, not general options.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure filenames are unique or override namespace.","message":"In customElement mode, custom element names are derived from the filename with a namespace prefix; conflicts may arise.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package: npm install esbuild-plugin-svg","cause":"Package not installed or import path incorrect.","error":"Error: Can't resolve 'esbuild-plugin-svg'"},{"fix":"Use: import svg from 'esbuild-plugin-svg'","cause":"Using named import instead of default import.","error":"TypeError: svg is not a function"},{"fix":"Add \"type\": \"module\" to package.json or use .mjs extension.","cause":"ESM syntax in CommonJS context without 'type': 'module'.","error":"Error: Invalid or unexpected token"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}