By default, svg-mixer only uses the SVG's file name as its ID. If any SVG files are stored in sub-directories, that information is ignored in the assembled spritesheet. This is problematic since context is lost (the sub-directory's name) and risks duplicate symbol IDs.
This PR introduces a new NPM dependency, common-path to resolve the longest common base path to be used as a prefix, and uses a dependency of svg-mixer named url-slug to sanitize the prefix.
Example for SVG source path ./assets/images/sprite:
By default,
svg-mixer
only uses the SVG's file name as its ID. If any SVG files are stored in sub-directories, that information is ignored in the assembled spritesheet. This is problematic since context is lost (the sub-directory's name) and risks duplicate symbol IDs.This PR introduces a new NPM dependency,
common-path
to resolve the longest common base path to be used as a prefix, and uses a dependency ofsvg-mixer
namedurl-slug
to sanitize the prefix.Example for SVG source path
./assets/images/sprite
:./assets/images/sprite/foo.svg
foo
./assets/images/sprite/baz/qux.svg
baz-qux