vant/packages/vant-icons/build/build-encode.js
2019-08-21 16:43:13 +08:00

22 lines
541 B
JavaScript

const fs = require('fs-extra');
const path = require('path');
const config = require('../src/config');
function template(fontName, ttf) {
return `@font-face {
font-weight: normal;
font-family: '${fontName}';
font-style: normal;
src: url('${ttf}') format('truetype');
}
`;
}
module.exports = function encode(fontName, srcDir) {
const ttfBase64 = fs.readFileSync(`../src/${fontName}.ttf`, 'base64');
fs.writeFileSync(
path.join(srcDir, 'encode.less'),
template(config.name, `data:font/ttf;base64,${ttfBase64}`)
);
};