Skip to content

Add watch mode for automatic SVG regeneration #22

@javierartero

Description

@javierartero

Is your feature request related to a problem? Please describe.

I'm always frustrated when I need to manually run svgpack every time I add or modify SVG files during development. This breaks the development flow.

Describe the solution you'd like

Add a --watch flag that monitors the SVG directory and automatically regenerates the CSS output on file changes.

svgpack src/assets/svg > output.css --mask --background --watch

The watch mode should:

  • Monitor the source directory for SVG changes (add/modify/delete)
  • Auto-regenerate output on changes
  • Handle errors without stopping

Describe alternatives you've considered

Using external watchers like nodemon or chokidar-cli:

{
  "scripts": {
    "watch:svg": "nodemon --watch src/assets/svg --ext svg --exec npm run build:svg"
  }
}

This works but requires extra dependencies.

Additional context

Would align svgpack with other build tools (Tailwind, TypeScript, PostCSS) that have native watch modes. Could use chokidar for the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions