如何使用webfont NPM?

时间:2017-03-30 08:46:45

标签: node.js webfonts

//app.js            
const webfont = require('webfont').default;

webfont({
    fontName: 'myfont',
    files: './src/*.ttf',
    formats: ['woff','eot']
}).then((res) => {
    console.log(res);
})

运行

节点app.js

错误:
UnhandledPromiseRejectionWarning:未处理的promise promise(拒绝ID:2):错误:指定的文件glob模式与任何文件都不匹配。

1 个答案:

答案 0 :(得分:0)

来自源代码:

var filteredFiles = foundFiles.filter(function (foundFile) {
            return _path2.default.extname(foundFile) === '.svg';
        });

        if (filteredFiles.length === 0) {
            throw new Error('Files glob patterns specified did not match any files');
        }

所以不幸的是你只能从svg转换。你必须改变来源。