我有一个有效的 Gulp 脚本,我用它来创建我的 SVG 精灵以及一个预览页面。但现在我想丰富预览页面,更准确地说是其中的每个图标,以及我在单独的 json 文件中拥有的信息。但我不知道如何做到这一点。
它应该看起来像这样:
function taskFactory(name, spriteMode) {
return gulp.src(srcSvgDir + '*.svg')
.pipe(svgSprite(config))
.pipe(jeditor((json) => {
// read json file for this sprite
// iterate entries in json
// Find the location in preview page (by selector or placeholder string) and paste the information from the json entry.
}))
.pipe(gulp.dest(destDir));
}
但我不知道我是否可以访问正在创建的预览页面。如果有人有完全不同的想法,我对任何事情都持开放态度。
在紧急情况下,我可以编写一个 C# 控制台应用程序,在创建精灵和预览页面后,解析和编辑后一个文件。不过我不认为这很好,因为我想纯粹用 Gulp 创建它。