jaywcjlove / svgtofont

Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font.
https://jaywcjlove.github.io/svgtofont
MIT License
515 stars 81 forks source link

CSSOptions include?: RegExp; issue #199

Closed hroma closed 1 year ago

hroma commented 1 year ago

Hi,

I just need the .scss file to be exported to the output path but It doesn't work (I don't need .less, .styl, .css, etc).

Simple javascript work as expected (just to test the regex) as used in utils.ts:

const filePath = 'hello.scss';
if ((new RegExp('scss$')).test(filePath)) {
  alert('it is a scss file');
} else {
  alert('it is not a scss file, add to removeFiles array');
}

My full code:

const svgtofont = require('svgtofont');
const path = require('path');
const CSSOptions = {
    include: "scss$",
    output: 'src/css',
  };

svgtofont({
  src: path.resolve(process.cwd(), '../public/assets/icons'), // svg path
  dist: path.resolve(process.cwd(), '../public/assets/fonts'), // output path
  fontName: 'icons', // font name
  classNamePrefix: "icon",
  svgicons2svgfont: {
    fontHeight: 1000,
    normalize: true
  },
  css: CSSOptions, 
}).then(() => {
  //console.log('done!');
});
jaywcjlove commented 1 year ago

Are you sure there is no configuration in package.json? @hroma

This will override your parameter configuration

https://github.com/jaywcjlove/svgtofont/blob/5c514f1ecb99f3c66f85637eb70f362d4473d993/package.json#L27-L31

hroma commented 1 year ago

Hi, I think the issue appear (only?) when dist (where fonts will be located) is outside the project folder... Seems that file are placed inside the dist folder, then removed, and moved to CSSOptions:output folder where it lead to permissions errors...

So, in my case:

dist = ../public/assets/fonts' (folder outside folder)
CSSOptions:output = 'src/css' (same folder)
jaywcjlove commented 1 year ago

Do you want to save it in a different directory? @hroma

If so, I recommend using a cpy-cli tool.

hroma commented 1 year ago

Thanks, cpy-cli did the trick.