Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More information about including the filePath of a specific sprite in the SPRITES_META variable #143

Open
Volosojui opened this issue May 16, 2024 · 0 comments

Comments

@Volosojui
Copy link

Volosojui commented May 16, 2024

Hi! I tried to follow the instructions here https://neodx.pages.dev/svg/group-and-hash.html to add a hash to the sprite file name and then use its name with hash in my Icon component (filePath), but I ran into trouble with the fact that SPRITES_META did not include filePath. After some searching I realized that to generate filePath you need to specify either size or viewBox in the metadata.runtime (https://github.com/secundant/neodx/blob/main/libs/svg/src/plugins/metadata.ts#L66-L91).

Maybe it should be included in the official documentation in the second step at https://neodx.pages.dev/svg/group-and-hash.html

Below are the configs that generate sprites containing hashes in their names but with and without the filePath key in SPRITES_META

SPRITES_META does not include the filePath:

svg({
  root: 'src/assets',
  output: 'public/sprites',
  fileName: '{name}.{hash:8}.svg',
  metadata: {
    path: 'src/shared/ui/components/icon/sprite.gen.ts',
  },
  resetColors: {
    replaceUnknown: 'currentColor',
  },
}),

SPRITES_META includes the filePath:

svg({
  root: 'src/assets',
  output: 'public/sprites',
  fileName: '{name}.{hash:8}.svg',
  metadata: {
    path: 'src/shared/ui/components/icon/sprite.gen.ts',
    runtime: {
      size: true
    }
  },
  resetColors: {
    replaceUnknown: 'currentColor',
  },
}),

And thanks for your project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant