mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 05:42:44 +08:00
build(@vant/icons): remove legacy build config
This commit is contained in:
parent
3eff0ad87a
commit
c08da62044
3
packages/vant-icons/.gitignore
vendored
3
packages/vant-icons/.gitignore
vendored
@ -1,4 +1 @@
|
||||
assets/svg
|
||||
src/*.ttf
|
||||
src/*.woff
|
||||
src/*.woff2
|
||||
|
@ -1,6 +0,0 @@
|
||||
|
||||
plugins:
|
||||
- removeAttrs:
|
||||
attrs:
|
||||
- 'fill'
|
||||
- 'stroke'
|
@ -30,5 +30,4 @@ yarn add @vant/icons
|
||||
|
||||
1. Add new icon to assets/icons.sketch
|
||||
2. Add icon name to src/config.js
|
||||
3. Add icon codepoints to build/codepoints.js
|
||||
4. Make a Pull Request
|
||||
3. Make a Pull Request
|
||||
|
@ -1,21 +0,0 @@
|
||||
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}`)
|
||||
);
|
||||
};
|
@ -1,78 +0,0 @@
|
||||
/**
|
||||
* build iconfont from sketch
|
||||
*/
|
||||
const { src, dest, series } = require('gulp');
|
||||
const fs = require('fs-extra');
|
||||
const glob = require('fast-glob');
|
||||
const shell = require('shelljs');
|
||||
const encode = require('./build-encode');
|
||||
const md5File = require('md5-file');
|
||||
const iconfont = require('gulp-iconfont');
|
||||
const iconfontCss = require('gulp-iconfont-css');
|
||||
const config = require('../src/config');
|
||||
const codepoints = require('./codepoints');
|
||||
const { join } = require('path');
|
||||
|
||||
const srcDir = join(__dirname, '../src');
|
||||
const svgDir = join(__dirname, '../assets/svg');
|
||||
const sketch = join(__dirname, '../assets/icons.sketch');
|
||||
const template = join(__dirname, './template.tpl');
|
||||
const formats = ['ttf', 'woff', 'woff2'];
|
||||
|
||||
// get md5 from sketch
|
||||
const md5 = md5File.sync(sketch).slice(0, 6);
|
||||
const fontName = `${config.name}-${md5}`;
|
||||
|
||||
// remove previous fonts
|
||||
const prevFonts = glob.sync(formats.map((ext) => join(srcDir, '*.' + ext)));
|
||||
prevFonts.forEach((font) => fs.removeSync(font));
|
||||
|
||||
// generate font from svg && build index.less
|
||||
function font() {
|
||||
return src([`${svgDir}/*.svg`])
|
||||
.pipe(
|
||||
iconfontCss({
|
||||
fontName: config.name,
|
||||
path: template,
|
||||
targetPath: '../src/index.less',
|
||||
normalize: true,
|
||||
fixedCodepoints: codepoints,
|
||||
cssClass: fontName, // this is a trick to pass fontName to template
|
||||
})
|
||||
)
|
||||
.pipe(
|
||||
iconfont({
|
||||
fontName,
|
||||
formats,
|
||||
})
|
||||
)
|
||||
.pipe(dest(srcDir));
|
||||
}
|
||||
|
||||
function encodeWoff2(done) {
|
||||
const cdnPath = `https://b.yzcdn.cn/vant/${fontName}.woff2`;
|
||||
const srcFile = join(srcDir, 'index.less');
|
||||
const woff2Base64 = fs.readFileSync(`../src/${fontName}.woff2`, 'base64');
|
||||
const woff2DataUrl = `data:font/ttf;base64,${woff2Base64}`;
|
||||
|
||||
fs.writeFileSync(
|
||||
join(srcDir, 'encode-woff2.less'),
|
||||
fs.readFileSync(srcFile, 'utf-8').replace(cdnPath, woff2DataUrl)
|
||||
);
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
function upload(done) {
|
||||
// generate encode.less
|
||||
encode(fontName, srcDir);
|
||||
|
||||
// upload font to cdn
|
||||
formats.forEach((ext) => {
|
||||
shell.exec(`superman-cdn /vant ${join(srcDir, fontName + '.' + ext)}`);
|
||||
});
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
exports.default = series(font, encodeWoff2, upload);
|
@ -1,250 +0,0 @@
|
||||
/* eslint-disable no-useless-escape */
|
||||
const map = {
|
||||
F000: 'add-o',
|
||||
F001: 'add-square',
|
||||
F002: 'add',
|
||||
F003: 'after-sale',
|
||||
F004: 'aim',
|
||||
F005: 'alipay',
|
||||
F006: 'apps-o',
|
||||
F007: 'arrow-down',
|
||||
F008: 'arrow-left',
|
||||
F009: 'arrow-up',
|
||||
F00A: 'arrow',
|
||||
F00B: 'ascending',
|
||||
F00C: 'audio',
|
||||
F00D: 'award-o',
|
||||
F00E: 'award',
|
||||
F00F: 'bag-o',
|
||||
F010: 'bag',
|
||||
F011: 'balance-list-o',
|
||||
F012: 'balance-list',
|
||||
F013: 'balance-o',
|
||||
F014: 'balance-pay',
|
||||
F015: 'bar-chart-o',
|
||||
F016: 'bars',
|
||||
F017: 'bell',
|
||||
F018: 'bill-o',
|
||||
F019: 'bill',
|
||||
F01A: 'birthday-cake-o',
|
||||
F01B: 'bookmark-o',
|
||||
F01C: 'bookmark',
|
||||
F01D: 'browsing-history-o',
|
||||
F01E: 'browsing-history',
|
||||
F01F: 'brush-o',
|
||||
F020: 'bulb-o',
|
||||
F021: 'bullhorn-o',
|
||||
F022: 'calendar-o',
|
||||
F023: 'card',
|
||||
F024: 'cart-circle-o',
|
||||
F025: 'cart-circle',
|
||||
F026: 'cart-o',
|
||||
F027: 'cart',
|
||||
F028: 'cash-back-record',
|
||||
F029: 'cash-on-deliver',
|
||||
F02A: 'cashier-o',
|
||||
F02B: 'certificate',
|
||||
F02C: 'chart-trending-o',
|
||||
F02D: 'chat-o',
|
||||
F02E: 'chat',
|
||||
F02F: 'checked',
|
||||
F030: 'circle',
|
||||
F031: 'clear',
|
||||
F032: 'clock-o',
|
||||
F033: 'clock',
|
||||
F034: 'close',
|
||||
F035: 'closed-eye',
|
||||
F036: 'cluster-o',
|
||||
F037: 'cluster',
|
||||
F038: 'column',
|
||||
F039: 'comment-circle-o',
|
||||
F03A: 'comment-circle',
|
||||
F03B: 'comment-o',
|
||||
F03C: 'comment',
|
||||
F03D: 'completed',
|
||||
F03E: 'contact',
|
||||
F03F: 'coupon-o',
|
||||
F040: 'coupon',
|
||||
F041: 'credit-pay',
|
||||
F042: 'cross',
|
||||
F043: 'debit-pay',
|
||||
F044: 'delete',
|
||||
F045: 'descending',
|
||||
F046: 'description',
|
||||
F047: 'desktop-o',
|
||||
F048: 'diamond-o',
|
||||
F049: 'diamond',
|
||||
F04A: 'discount',
|
||||
F04B: 'down',
|
||||
F04C: 'ecard-pay',
|
||||
F04D: 'edit',
|
||||
F04E: 'ellipsis',
|
||||
F04F: 'empty',
|
||||
F050: 'envelop-o',
|
||||
F051: 'exchange',
|
||||
F052: 'expand-o',
|
||||
F053: 'expand',
|
||||
F054: 'eye-o',
|
||||
F055: 'eye',
|
||||
F056: 'fail',
|
||||
F057: 'failure',
|
||||
F058: 'filter-o',
|
||||
F059: 'fire-o',
|
||||
F05A: 'fire',
|
||||
F05B: 'flag-o',
|
||||
F05C: 'flower-o',
|
||||
F05D: 'free-postage',
|
||||
F05E: 'friends-o',
|
||||
F05F: 'friends',
|
||||
F060: 'gem-o',
|
||||
F061: 'gem',
|
||||
F062: 'gift-card-o',
|
||||
F063: 'gift-card',
|
||||
F064: 'gift-o',
|
||||
F065: 'gift',
|
||||
F066: 'gold-coin-o',
|
||||
F067: 'gold-coin',
|
||||
F068: 'good-job-o',
|
||||
F069: 'good-job',
|
||||
F06A: 'goods-collect-o',
|
||||
F06B: 'goods-collect',
|
||||
F06C: 'graphic',
|
||||
F06D: 'home-o',
|
||||
F06E: 'hot-o',
|
||||
F06F: 'hot-sale-o',
|
||||
F070: 'hot-sale',
|
||||
F071: 'hot',
|
||||
F072: 'hotel-o',
|
||||
F073: 'idcard',
|
||||
F074: 'info-o',
|
||||
F075: 'info',
|
||||
F076: 'invition',
|
||||
F077: 'label-o',
|
||||
F078: 'label',
|
||||
F079: 'like-o',
|
||||
F07A: 'like',
|
||||
F07B: 'live',
|
||||
F07C: 'location-o',
|
||||
F07D: 'location',
|
||||
F07E: 'lock',
|
||||
F07F: 'logistics',
|
||||
F080: 'manager-o',
|
||||
F081: 'manager',
|
||||
F082: 'map-marked',
|
||||
F083: 'medal-o',
|
||||
F084: 'medal',
|
||||
F085: 'more-o',
|
||||
F086: 'more',
|
||||
F087: 'music-o',
|
||||
F088: 'music',
|
||||
F089: 'new-arrival-o',
|
||||
F08A: 'new-arrival',
|
||||
F08B: 'new-o',
|
||||
F08C: 'new',
|
||||
F08D: 'newspaper-o',
|
||||
F08E: 'notes-o',
|
||||
F08F: 'orders-o',
|
||||
F090: 'other-pay',
|
||||
F091: 'paid',
|
||||
F092: 'passed',
|
||||
F093: 'pause-circle-o',
|
||||
F094: 'pause-circle',
|
||||
F095: 'pause',
|
||||
F096: 'peer-pay',
|
||||
F097: 'pending-payment',
|
||||
F098: 'phone-circle-o',
|
||||
F099: 'phone-circle',
|
||||
F09A: 'phone-o',
|
||||
F09B: 'phone',
|
||||
F09C: 'photo-o',
|
||||
F09D: 'photo',
|
||||
F09E: 'photograph',
|
||||
F09F: 'play-circle-o',
|
||||
F0A0: 'play-circle',
|
||||
F0A1: 'play',
|
||||
F0A2: 'plus',
|
||||
F0A3: 'point-gift-o',
|
||||
F0A4: 'point-gift',
|
||||
F0A5: 'points',
|
||||
F0A6: 'printer',
|
||||
F0A7: 'qr-invalid',
|
||||
F0A8: 'qr',
|
||||
F0A9: 'question-o',
|
||||
F0AA: 'question',
|
||||
F0AB: 'records',
|
||||
F0AC: 'refund-o',
|
||||
F0AD: 'replay',
|
||||
F0AE: 'scan',
|
||||
F0AF: 'search',
|
||||
F0B0: 'send-gift-o',
|
||||
F0B1: 'send-gift',
|
||||
F0B2: 'service-o',
|
||||
F0B3: 'service',
|
||||
F0B4: 'setting-o',
|
||||
F0B5: 'setting',
|
||||
F0B6: 'share',
|
||||
F0B7: 'shop-collect-o',
|
||||
F0B8: 'shop-collect',
|
||||
F0B9: 'shop-o',
|
||||
F0BA: 'shop',
|
||||
F0BB: 'shopping-cart-o',
|
||||
F0BC: 'shopping-cart',
|
||||
F0BD: 'shrink',
|
||||
F0BE: 'sign',
|
||||
F0BF: 'smile-comment-o',
|
||||
F0C0: 'smile-comment',
|
||||
F0C1: 'smile-o',
|
||||
F0C2: 'smile',
|
||||
F0C3: 'star-o',
|
||||
F0C4: 'star',
|
||||
F0C5: 'stop-circle-o',
|
||||
F0C6: 'stop-circle',
|
||||
F0C7: 'stop',
|
||||
F0C8: 'success',
|
||||
F0C9: 'thumb-circle-o',
|
||||
F0CA: 'thumb-circle',
|
||||
F0CB: 'todo-list-o',
|
||||
F0CC: 'todo-list',
|
||||
F0CD: 'tosend',
|
||||
F0CE: 'tv-o',
|
||||
F0CF: 'umbrella-circle',
|
||||
F0D0: 'underway-o',
|
||||
F0D1: 'underway',
|
||||
F0D2: 'upgrade',
|
||||
F0D3: 'user-circle-o',
|
||||
F0D4: 'user-o',
|
||||
F0D5: 'video-o',
|
||||
F0D6: 'video',
|
||||
F0D7: 'vip-card-o',
|
||||
F0D8: 'vip-card',
|
||||
F0D9: 'volume-o',
|
||||
F0DA: 'volume',
|
||||
F0DB: 'wap-home-o',
|
||||
F0DC: 'wap-home',
|
||||
F0DD: 'wap-nav',
|
||||
F0DE: 'warn-o',
|
||||
F0DF: 'warning-o',
|
||||
F0E0: 'warning',
|
||||
F0E1: 'weapp-nav',
|
||||
F0E2: 'wechat-pay',
|
||||
F0E3: 'youzan-shield',
|
||||
F0E4: 'enlarge',
|
||||
F0E5: 'photo-fail',
|
||||
F0E6: 'back-top',
|
||||
F0E7: 'share-o',
|
||||
F0E8: 'minus',
|
||||
F0E9: 'delete-o',
|
||||
F0EA: 'sort',
|
||||
F0EB: 'font',
|
||||
F0EC: 'font-o',
|
||||
F0ED: 'revoke',
|
||||
F0EE: 'wechat',
|
||||
};
|
||||
|
||||
const reversedMap = {};
|
||||
|
||||
Object.keys(map).forEach((key) => {
|
||||
reversedMap[map[key]] = key;
|
||||
});
|
||||
|
||||
module.exports = reversedMap;
|
@ -1,19 +0,0 @@
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const shell = require('shelljs');
|
||||
|
||||
const svgDir = path.join(__dirname, '../assets/svg');
|
||||
const sketch = path.join(__dirname, '../assets/icons.sketch');
|
||||
const SKETCH_TOOL_DIR =
|
||||
'/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool';
|
||||
|
||||
fs.removeSync(svgDir);
|
||||
|
||||
// extract svg from sketch
|
||||
// should install sketchtool first
|
||||
// install guide: https://developer.sketchapp.com/guides/sketchtool/
|
||||
shell.exec(
|
||||
`${SKETCH_TOOL_DIR} export slices --formats=svg --overwriting=YES --save-for-web=YES --output=${svgDir} ${sketch}`
|
||||
);
|
||||
|
||||
shell.exec('svgo ./assets/svg/*.svg');
|
@ -1,30 +0,0 @@
|
||||
/* stylelint-disable selector-pseudo-element-colon-notation */
|
||||
/* stylelint-disable font-family-no-missing-generic-family-keyword */
|
||||
@font-face {
|
||||
font-weight: normal;
|
||||
font-family: '<%= fontName %>';
|
||||
font-style: normal;
|
||||
font-display: auto;
|
||||
src: url('https://b.yzcdn.cn/vant/<%= cssClass %>.woff2') format('woff2'),
|
||||
url('https://b.yzcdn.cn/vant/<%= cssClass %>.woff') format('woff'),
|
||||
url('https://b.yzcdn.cn/vant/<%= cssClass %>.ttf') format('truetype');
|
||||
}
|
||||
|
||||
.van-icon {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
font: normal normal normal 14px/1 '<%= fontName %>';
|
||||
font-size: inherit;
|
||||
text-rendering: auto;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
&::before {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
<% _.each(glyphs, function(glyph) { %>.van-icon-<%= glyph.fileName %>::before {
|
||||
content: '\<%= glyph.codePoint %>';
|
||||
}
|
||||
|
||||
<% }); %>
|
@ -12,22 +12,12 @@
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"scripts": {
|
||||
"export": "node ./build/export.js",
|
||||
"build": "npm run export && gulp --gulpfile ./build/build-iconfont.js",
|
||||
"release": "npm run build && release-it"
|
||||
"release": "release-it"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-icons",
|
||||
"devDependencies": {
|
||||
"fast-glob": "^3.2.2",
|
||||
"fs-extra": "^9.0.1",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-iconfont": "^10.0.3",
|
||||
"gulp-iconfont-css": "^3.0.0",
|
||||
"md5-file": "^5.0.0",
|
||||
"release-it": "^13.6.2",
|
||||
"shelljs": "^0.8.4",
|
||||
"svgo": "1.2.2"
|
||||
"release-it": "^13.6.2"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user