allanguys / font-spider-plus Goto Github PK
View Code? Open in Web Editor NEWfont-spider-plus(字蛛+)是一个智能 WebFont 压缩工具,它能自动分析出本地页面和线上页面使用的 WebFont 并进行按需压缩。
License: MIT License
font-spider-plus(字蛛+)是一个智能 WebFont 压缩工具,它能自动分析出本地页面和线上页面使用的 WebFont 并进行按需压缩。
License: MIT License
关于不支持'https' 的在线地址解析,感觉这是一个大问题。。。。不知道是否能够解决
$ fsp run
⠋ 配 置 读 取 完 成 (node:1898021) MaxListenersExceededWarning:
Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1898021) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:1898021) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:1898021) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
⠙ 正 在 分 析 配 置 中 的 网 址 .../usr/local/share/.config/yarn/global/node_modules/puppeteer/lib/Launcher.js:348
reject(new Error([
^
Error: Failed to launch chrome!
/usr/local/share/.config/yarn/global/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error
while loading shared libraries: libXdamage.so.1: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/usr/local/share/.config/yarn/global/node_modules/puppeteer/lib/Launcher.js:348:14)
at Interface.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/puppeteer/lib/Launcher.js:337:50)
at Interface.emit (node:events:525:35)
at Interface.emit (node:domain:489:12)
at Interface.close (node:internal/readline/interface:534:10)
at Socket.onend (node:internal/readline/interface:260:10)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Node.js v19.4.0
希望加上
ouis@louisdeMacBook-Pro assets % fsp run
✔ 页面分析完成
/Users/louis/.nvm/versions/node/v16.0.0/lib/node_modules/font-spider-plus/bin/index.js:250
if(webFonts[0].chars === ''){
^
TypeError: Cannot read property 'chars' of undefined
at /Users/louis/.nvm/versions/node/v16.0.0/lib/node_modules/font-spider-plus/bin/index.js:250:28
at CB (/Users/louis/.nvm/versions/node/v16.0.0/lib/node_modules/font-spider-plus/node_modules/fs-extra/lib/remove/rimraf.js:57:5)
at FSReqCallback.oncomplete (node:fs:184:23)
我的本地网页中使用了相对路径:\css\index.css
运行fsp local **\*.html时,fsp却报错找不到:D:\\css\\index.css
Error: Failed to launch chrome!
\ 正在分析配置中的网址...(node:16832) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'push' of undefined
at intoTokens (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\tokenizer\tokenize.js:311:17)
at tokenize (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\tokenizer\tokenize.js:77:10)
at fromStyles (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\reader\read-sources.js:147:12)
at fromString (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\reader\read-sources.js:48:10)
at doReadSources (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\reader\read-sources.js:33:12)
at readSources (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\reader\read-sources.js:24:10)
at C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\clean.js:115:12
at C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\clean.js:135:34
at minify (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\clean.js:114:35)
at CleanCSS.minify (C:\Users\EmptyDreams\AppData\Roaming\npm\node_modules\font-spider-plus\node_modules\clean-css\lib\clean.js:77:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16832) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16832) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
{
"localPath" : "../source/self/fonts/",
"onlinePath" : "../self/fonts/",
"url" : [
"http://localhost:4000/"
]
}
注:服务器在本地上,用hexo s
生成的,所以用的本地链接
Error: "//fn.qq.com/web2018../font/fn.ttf" file not found
at Compress.min (/home/user/temp/node_modules/font-spider/src/compressor/index.js:131:29)
at Compress. (/home/user/temp/node_modules/font-spider/src/compressor/index.js:63:22)
at DestroyableTransform.emit (events.js:187:15)
at /home/user/temp/node_modules/gulp/node_modules/readable-stream/lib/_stream_readable.js:965:16
at process._tickCallback (internal/process/next_tick.js:61:11)
Could you please share more examples for the parameters usage?
font.css:
@font-face {
font-family: 'SourceHanSerifCN';
src: url('SourceHanSerifCN-Bold.ttf');
font-weight: normal;
font-style: normal;
}
body{
font-family: 'SourceHanSerifCN';
}
运行:fsp local index.html如下:
\ 正在优化...not support cmap format:14
√ 没有发现可以优化的自定义字体
重新启动项目发现字体又恢复原来的样式了。
fsp run
的时候出现如下错误:
⠋ 配置读取完成(node:16680) UnhandledPromiseRejectionWarning: Error: Chromium revision is not downloaded. Run "npm install" or "yarn install"
at Launcher.launch (/root/.nvm/versions/node/v12.12.0/lib/node_modules/font-spider-plus/node_modules/puppeteer/lib/Launcher.js:119:15)
at async /root/.nvm/versions/node/v12.12.0/lib/node_modules/font-spider-plus/bin/index.js:148:33
(node:16680) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16680) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
已安装 chromium……
正在分析配置中的网址...(node:12524) UnhandledPromiseRejectionWarning: TimeoutE
rror: Navigation Timeout Exceeded: 30000ms exceeded;
demo也会出现这种问题
在生产环境 运行fsp run的时候,出现
undefined:7 ] ^ SyntaxError: Unexpected token ] in JSON at position 137 at JSON.parse (<anonymous>) at checkFile (/usr/local/lib/node_modules/font-spider-plus/bin/index.js:115:23) at doM (/usr/local/lib/node_modules/font-spider-plus/bin/index.js:133:9) at Command.<anonymous> (/usr/local/lib/node_modules/font-spider-plus/bin/index.js:49:9) at Command.listener (/usr/local/lib/node_modules/font-spider-plus/node_modules/[email protected]@commander/index.js:315:8) at Command.emit (events.js:182:13) at Command.parseArgs (/usr/local/lib/node_modules/font-spider-plus/node_modules/[email protected]@commander/index.js:654:12) at Command.parse (/usr/local/lib/node_modules/font-spider-plus/node_modules/[email protected]@commander/index.js:474:21)
还有一个问题是 localPath 是相对于根目录即vue.config.js这层么? onlinePath 则是相对于 打包好的
dist目录么?
因为我的字体文件有的是cdn上的,有的是项目里的。所以希望onlinePath可以支持多个
一个简单的demo 只有一个html文件,js内嵌 。
Ubuntu14.04.
node: v8.15.0.
运行fsp local index.html 或 sudo fsp local index.html 得以下报错:
正在优化...Parsing of the input font failed.
麻烦问下大概什么问题?
从源代码中并没有发现处理动态文本的相关逻辑 ;
请问作者是如何实现的 ?
是否有相关详细的api注解
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.