Skip to content

Instantly share code, notes, and snippets.

@ChucKN0risK
Created October 28, 2021 21:02
Show Gist options
  • Save ChucKN0risK/25ac56d96c090c9b37918ecbadfa067c to your computer and use it in GitHub Desktop.
Save ChucKN0risK/25ac56d96c090c9b37918ecbadfa067c to your computer and use it in GitHub Desktop.
Specify config to get vectors in .tsx
{
"repository": "",
"personalAccessToken": "",
"rules": [
{
"name": "Assets / Vector",
"path": "src/components/core/Icon/vectors/",
"filter": {
"types": [
"vector"
]
},
"parsers": [
// Creates a property fileName that will be used
// to create the file and the directories.
// Allows you to add .tsx extension instead of .jsx by default
{
"name": "name-assets-files-by-pattern",
"options": {
"pattern": "{{name}}.tsx"
}
},
// Removes all characters before the last slash
// to use the name of the vector as a variable name
// in you .jsx file. "export const variableName = () => (...)"
{
"name": "replace-string",
"options": {
"keys": ["name"],
"regex": {
"pattern": "(.*?)\\/",
"flags": "g"
},
"trim": true
}
},
// Pay attention not to use the `variableFormat` property
// with `exportDefault` set as `true`.
// It will generate the following invalid JS string:
// `export default const iconName = () => (...)`
{
"name": "svg-to-jsx",
"options": {
"prepend": "import React from 'react';",
"variableFormat": "camelCase",
"formatConfig": {
"exportDefault": false,
"singleQuote": true
}
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment