mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
[new feature] normalize size of all icons (#292)
* [bugfix] CouponList always show empty info * [bugfix] add click feedback of buttons in components * [Doc] add custom theme document * [new feature] Notice bar support more props * [bugfix] PullRefresh test cases * [bugfix] unused NoticeBar style * [bugfix] Swipe width calc error * [Doc] english document of all action components * [Doc] change document site path to /zanui/vant * [Doc] fix * [bugfix] uploader style error * [bugfix] tabs document demo * [new feature] Cell support vue-router target route * [bugfix] add cell test cases * update yarn.lock * [bugfix] Tabbar cann't display info when use icon slot * [Doc] update document title * [bugfix] Dialog should reset button text when showed * [new feature] CouponList add showCloseButton prop * [new feature] Swipe add 'initialSwipe' prop * [bugfix] NoticeBar text disappeared when page back * [new feature] ImagePreview support startPosition * fix: improve imagePreview test cases * [bugfix] Steps style error when has more than 4 items * [new feature] normalize size of all icons
This commit is contained in:
@@ -1,12 +1,77 @@
|
||||
const gulp = require('gulp');
|
||||
const postcss = require('gulp-postcss');
|
||||
const cssmin = require('gulp-clean-css');
|
||||
const iconfont = require('gulp-iconfont');
|
||||
const iconfontCss = require('gulp-iconfont-css');
|
||||
const fs = require('fs-extra');
|
||||
const config = require('./scripts/icon-config');
|
||||
const path = require('path');
|
||||
const shelljs = require('shelljs');
|
||||
const md5File = require('md5-file');
|
||||
|
||||
function extractSvg() {
|
||||
shelljs.exec('./scripts/extract-icons.sh');
|
||||
fs.mkdirsSync(path.join(__dirname, './icons'));
|
||||
config.glyphs.forEach(icon => {
|
||||
const src = path.join(__dirname, './icons/', icon.src);
|
||||
if (fs.existsSync(src)) {
|
||||
fs.renameSync(src, path.join(__dirname, './icons', icon.css + '.svg'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getCodePoints() {
|
||||
const codePoints = {};
|
||||
config.glyphs.forEach((icon, index) => {
|
||||
const svgPath = path.join(__dirname, './icons/', icon.css + '.svg');
|
||||
if (fs.existsSync(svgPath)) {
|
||||
codePoints[icon.css] = 0xe800 + index;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('compile', () => {
|
||||
return gulp.src('./src/*.css')
|
||||
return gulp
|
||||
.src('./src/*.css')
|
||||
.pipe(postcss())
|
||||
.pipe(cssmin())
|
||||
.pipe(gulp.dest('./lib'));
|
||||
});
|
||||
|
||||
gulp.task('icon-font-ttf', () => {
|
||||
extractSvg();
|
||||
return gulp
|
||||
.src(['icons/*.svg'])
|
||||
.pipe(
|
||||
iconfontCss({
|
||||
fontName: config.name,
|
||||
path: 'scripts/icon-template.css',
|
||||
targetPath: './icon.css',
|
||||
normalize: true,
|
||||
firstGlyph: 0xe800,
|
||||
fixedCodepoints: getCodePoints()
|
||||
})
|
||||
)
|
||||
.pipe(
|
||||
iconfont({
|
||||
fontName: config.name,
|
||||
formats: ['ttf']
|
||||
})
|
||||
)
|
||||
.on('glyphs', (glyphs, options) => {})
|
||||
.pipe(gulp.dest('icons'));
|
||||
});
|
||||
|
||||
gulp.task('icon-font', ['icon-font-ttf'], () => {
|
||||
const fontPath = path.resolve(__dirname, './icons/vant-icon.ttf');
|
||||
const hash = md5File.sync(fontPath).slice(0, 8);
|
||||
fs.renameSync(fontPath, path.resolve(__dirname, `./icons/vant-icon-${hash}.ttf`));
|
||||
|
||||
let source = fs.readFileSync(path.resolve(__dirname, './icons/icon.css'), 'utf-8');
|
||||
source = source.replace('vant-icon.ttf', `vant-icon-${hash}.ttf`);
|
||||
|
||||
fs.writeFileSync(path.resolve(__dirname, './src/icon.css'), source);
|
||||
shelljs.exec(`superman cdn /zanui/icon ./icons/vant-icon-${hash}.ttf`);
|
||||
});
|
||||
|
||||
gulp.task('build', ['compile']);
|
||||
|
Reference in New Issue
Block a user