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

--ignore的正确用法? #129

Open
nicholaelaw opened this issue May 18, 2017 · 6 comments
Open

--ignore的正确用法? #129

nicholaelaw opened this issue May 18, 2017 · 6 comments

Comments

@nicholaelaw
Copy link

nicholaelaw commented May 18, 2017

我实在是搞不懂了……求各位指教:

我要排除两个字体家族,FontAwesome和Glyphicons Halflings。目录结构:

- example <-- 根目录,所有html文件都在这,shell位置。
  - site
    - libs
      - bootstrap
        - fonts
          - glyphicons-halflings-regular.eot/svg/ttf/woff/woff2 <-- 忽略
      - font-awesome
        - fontawesome-webfont.ttf                               <-- 忽略
  - styles
    - fontawesome 
      - fontawesome-webfont.eot/svg/ttf/woff/woff2              <-- 忽略
    - fonts
      - 中文字体.oet/svg/ttf/woff/woff2                          <-- 不忽略

先尝试仅排除第二个FA字体:

--ignore styles/fontawesome/fontawesome-webfont*

返回结果

{ id: '5a5350b6467773a79b6dca14cdb05b5a',
  family: 'FontAwesome-web',
  files:
   [ { url: 'example/styles/fontawesome/fontawesome-webfont.woff2',
       format: 'woff2' },
     { url: 'example/styles/fontawesome/fontawesome-webfont.ttf',
       format: 'truetype' } ],
  style: 'normal',
  weight: '400',
  chars: '',
  selectors:
   [ '.fa',
     '.fa-home:before',
     '.fa-external-link:before',
     '.fa-table:before',
     '.fa-info:before' ] }

只排除了部分字体文件?再尝试--ignore fontawesome*, glyphicons*,结果

{ id: '340feb78c2efa220dd893149c2ebf450',
  family: 'Glyphicons Halflings',
  files:
   [ { url: 'example/_site/libs/bootstrap/fonts/glyphicons-halflings-regular.woff',
       format: 'woff' },
     { url: 'example/_site/libs/bootstrap/fonts/glyphicons-halflings-regular.svg',
       format: 'svg' } ],
  chars: '',
  selectors: [ '.glyphicon' ] },
{ id: '7790cf9678b2d256ac0107bea9d0834d',
  family: 'FontAwesome',
  files: [],
  style: 'normal',
  weight: 'normal',
  chars: '',
  selectors:
   [ '.fa',
     '.fa-home:before',
     '.fa-external-link:before',
     '.fa-table:before',
     '.fa-info:before' ] },
{ id: '5a5350b6467773a79b6dca14cdb05b5a',
  family: 'FontAwesome-web',
  files:
   [ { url: 'example/styles/fontawesome/fontawesome-webfont.woff',
       format: 'woff' } ],
  style: 'normal',
  weight: '400',
  chars: '',
  selectors:
   [ '.fa',
     '.fa-home:before',
     '.fa-external-link:before',
     '.fa-table:before',
     '.fa-info:before' ] } ]

一定是我用法不对……请各位指点,怎样才能把三个家族、十一个文件都排除出去~

@aui
Copy link
Owner

aui commented May 18, 2017

试试使用字符串的方式?--ignore "name"

@nicholaelaw
Copy link
Author

命令:

font-spider --ignore "fontawesome" --info example/*.html`

返回:

{ id: '5a5350b6467773a79b6dca14cdb05b5a',
  family: 'FontAwesome-web',
  files:
   [ { url: 'example/styles/fontawesome/fontawesome-webfont.woff',
       format: 'woff' } ],
  style: 'normal',
  weight: '400',
  chars: '',
  selectors:
   [ '.fa',
     '.fa-home:before',
     '.fa-external-link:before',
     '.fa-table:before',
     '.fa-info:before' ] } 

还是漏掉一个……另外字符串方式怎么指定多个匹配项呢?

@aui
Copy link
Owner

aui commented May 18, 2017

使用 , 分割即可

@nicholaelaw
Copy link
Author

nicholaelaw commented May 18, 2017

命令:

font-spider --ignore "fontawesome-webfont.eot,fontawesome-webfont.svg,fontawesome-webfont.ttf,fontawesome-webfont.woff,fontawesome-webfont.woff2,glyphicons-halflings-regular.eot,glyphicons-halflings-regular.svg,glyphicons-halflings-regular.ttf,glyphicons-halflings-regular.woff,glyphicons-halflings-regular.woff2" --info _site\*.html

还是不能排除所有文件:

{ id: '5c3cf3bbe37906a64d1f9e596b858bef',
  family: 'Glyphicons Halflings',
  files: [],
  chars: '',
  selectors: [ '.glyphicon' ] },
{ id: '47c35c895ca3f4b9272ceb0d4455bb16',
  family: 'FontAwesome',
  files: [],
  style: 'normal',
  weight: 'normal',
  chars: '',
  selectors:
   [ '.fa',
     '.fa-home:before',
     '.fa-external-link:before',
     '.fa-table:before',
     '.fa-info:before' ] },
{ id: '9019f2ae4540460a0fec5969430737d2',
  family: 'FontAwesome-web',
  files:
   [ { url: 'example/styles/fontawesome/fontawesome-webfont.woff',
       format: 'woff' } ],
  style: 'normal',
  weight: '400',
  chars: '',
  selectors:
   [ '.fa',
     '.fa-home:before',
     '.fa-external-link:before',
     '.fa-table:before',
     '.fa-info:before' ] }

文件名都是直接从输出复制粘贴过去的,我也是完全懵逼了。只有排除CSS文件才可以完全排除文件中定义的所有font-face,可是把不需要压缩的字体分离出来又不是那么简单……

@aui
Copy link
Owner

aui commented May 19, 2017

请提供一个demo

@nicholaelaw
Copy link
Author

demo.zip

./demo下运行font-spider --ignore fontawesome*,glyphicons* --info index.html,无法完全排除指定字体。

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