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

Adding svgoConfig file path as a command line argument #136

Closed
josealeixopc opened this issue Nov 11, 2021 · 4 comments
Closed

Adding svgoConfig file path as a command line argument #136

josealeixopc opened this issue Nov 11, 2021 · 4 comments

Comments

@josealeixopc
Copy link

Hello. First of all, thank you so much for maintaining this tool!

I've recently updated svg-to-ts to 7.1.0 and noticed that some of my icons were not scaling properly. I figured it had to do with SVGO setting removeViewBox as a default plugin. I wish to use my own SVGO config to disable this behavior.

I have added a svgo.config.js file to the root of my project and successfully gotten the desired behavior. However, I would like to keep the root folder as little "polluted" as possible. I was wondering if on the most recent version (7.1.0) there is a way of providing the path to the svgo.config.js file in the command line. If not, could you provide an example of a "inline configuration object" for the SVGO config?

Cheers!

@kreuzerk
Copy link
Owner

HI @josealeixopc thx a lot for the question. Currently, we don't support custom paths for svgo configs. However, you can always configure your svgo inline in your svg-to-ts config. See an example in the README where we configure svgo inside the svg-to-ts object in the package.json

@kreuzerk
Copy link
Owner

kreuzerk commented Nov 11, 2021

here's an example of inline svgo config inside the package.json

{
  "name": "my-icon-library",
  "version": "3.4.0",
  "scripts": {
    "generate-icons": "svg-to-ts"
  },
  "svg-to-ts": {
    "conversionType": "constants",
    "srcFiles": ["./projects/dinosaur-icons/icons/**/*.svg"],
    "outputDirectory": "./projects/dinosaur-icons/icons",
    "interfaceName": "DinosaurIcon",
    "typeName": "dinosaurIcon",
    "prefix": "dinosaurIcon",
    "svgoConfig": {
      "plugins": ["cleanupAttrs"]
    },
    "fileName": "dinosaur-icon.model",
    "additionalModelFile": "./projects/dinosaur-icons/src/lib",
    "compileSources": true
  }
}

@josealeixopc
Copy link
Author

Thanks @kreuzerk ! Passing the config using the svgoConifg field worked :)

@kreuzerk
Copy link
Owner

@josealeixopc 👍 Glad to hear that it worked

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

2 participants