问题标签 [grunt-svgstore]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
svg - 访问 grunt 任务中的文件名
我正在尝试用 Grunt 编辑很多 svg 文件。
我目前正在使用 svgmin 和 grunt-text-replace。
我需要根据文件名向 svg 元素添加属性。
我想知道是否有一种 grunt 模板可以让您获取正在处理的文件的名称。
这是我想要的:
这是当前脚本:
javascript - How to concatenate relative path or generate unique identifier svg contained in nested folders?
I have many icons exported by "Figma" in a folder structure, I have used grunt-svgstore to generate the sprite sheet but I'm getting duplicated ids in the result.
I have tried with "allowDuplicateItems: false" and "setUniqueIds: true" but it doesn't work.
Folder structure:
-icons
--arrow
---arrow-left
----scale.svg
---arrow-right
----scale.svg
--checkbox
---active.svg
---inactive.svg
--chevron
---left-chevron
----scale.svg
---right-chevron
----scale.svg
--etc.
Grunt file JS:
Expected result based on relative path
Actual result: