[gulpfile.js] Reduce unnecessary duplication when bundling CMap/StandardFont files
Rather than repeating the exact same code in multiple `gulp`-tasks, we can extract it into two helper functions instead.
This commit is contained in:
parent
16d9fa1bf1
commit
8f3f76f8f6
110
gulpfile.js
110
gulpfile.js
@ -499,6 +499,26 @@ function createImageDecodersBundle(defines) {
|
|||||||
.pipe(replaceJSRootName(imageDecodersAMDName, "pdfjsImageDecoders"));
|
.pipe(replaceJSRootName(imageDecodersAMDName, "pdfjsImageDecoders"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createCMapBundle() {
|
||||||
|
return gulp.src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], {
|
||||||
|
base: "external/bcmaps",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createStandardFontBundle() {
|
||||||
|
return gulp.src(
|
||||||
|
[
|
||||||
|
"external/standard_fonts/*.pfb",
|
||||||
|
"external/standard_fonts/*.ttf",
|
||||||
|
"external/standard_fonts/LICENSE_FOXIT",
|
||||||
|
"external/standard_fonts/LICENSE_LIBERATION",
|
||||||
|
],
|
||||||
|
{
|
||||||
|
base: "external/standard_fonts",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function checkFile(filePath) {
|
function checkFile(filePath) {
|
||||||
try {
|
try {
|
||||||
const stat = fs.lstatSync(filePath);
|
const stat = fs.lstatSync(filePath);
|
||||||
@ -807,24 +827,9 @@ function buildGeneric(defines, dir) {
|
|||||||
base: "web/",
|
base: "web/",
|
||||||
})
|
})
|
||||||
.pipe(gulp.dest(dir + "web")),
|
.pipe(gulp.dest(dir + "web")),
|
||||||
gulp
|
createCMapBundle().pipe(gulp.dest(dir + "web/cmaps")),
|
||||||
.src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], {
|
createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")),
|
||||||
base: "external/bcmaps",
|
|
||||||
})
|
|
||||||
.pipe(gulp.dest(dir + "web/cmaps")),
|
|
||||||
gulp
|
|
||||||
.src(
|
|
||||||
[
|
|
||||||
"external/standard_fonts/*.pfb",
|
|
||||||
"external/standard_fonts/*.ttf",
|
|
||||||
"external/standard_fonts/LICENSE_FOXIT",
|
|
||||||
"external/standard_fonts/LICENSE_LIBERATION",
|
|
||||||
],
|
|
||||||
{
|
|
||||||
base: "external/standard_fonts",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.pipe(gulp.dest(dir + "web/standard_fonts")),
|
|
||||||
preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")),
|
preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")),
|
||||||
preprocessCSS("web/viewer.css", "generic", defines, true)
|
preprocessCSS("web/viewer.css", "generic", defines, true)
|
||||||
.pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)]))
|
.pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)]))
|
||||||
@ -988,24 +993,8 @@ function buildMinified(defines, dir) {
|
|||||||
base: "web/",
|
base: "web/",
|
||||||
})
|
})
|
||||||
.pipe(gulp.dest(dir + "web")),
|
.pipe(gulp.dest(dir + "web")),
|
||||||
gulp
|
createCMapBundle().pipe(gulp.dest(dir + "web/cmaps")),
|
||||||
.src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], {
|
createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")),
|
||||||
base: "external/bcmaps",
|
|
||||||
})
|
|
||||||
.pipe(gulp.dest(dir + "web/cmaps")),
|
|
||||||
gulp
|
|
||||||
.src(
|
|
||||||
[
|
|
||||||
"external/standard_fonts/*.pfb",
|
|
||||||
"external/standard_fonts/*.ttf",
|
|
||||||
"external/standard_fonts/LICENSE_FOXIT",
|
|
||||||
"external/standard_fonts/LICENSE_LIBERATION",
|
|
||||||
],
|
|
||||||
{
|
|
||||||
base: "external/standard_fonts",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.pipe(gulp.dest(dir + "web/standard_fonts")),
|
|
||||||
|
|
||||||
preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")),
|
preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")),
|
||||||
preprocessCSS("web/viewer.css", "minified", defines, true)
|
preprocessCSS("web/viewer.css", "minified", defines, true)
|
||||||
@ -1235,24 +1224,13 @@ gulp.task(
|
|||||||
gulp
|
gulp
|
||||||
.src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" })
|
.src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" })
|
||||||
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")),
|
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")),
|
||||||
gulp
|
createCMapBundle().pipe(
|
||||||
.src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], {
|
gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/cmaps")
|
||||||
base: "external/bcmaps",
|
),
|
||||||
})
|
createStandardFontBundle().pipe(
|
||||||
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/cmaps")),
|
gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/standard_fonts")
|
||||||
gulp
|
),
|
||||||
.src(
|
|
||||||
[
|
|
||||||
"external/standard_fonts/*.pfb",
|
|
||||||
"external/standard_fonts/*.ttf",
|
|
||||||
"external/standard_fonts/LICENSE_FOXIT",
|
|
||||||
"external/standard_fonts/LICENSE_LIBERATION",
|
|
||||||
],
|
|
||||||
{
|
|
||||||
base: "external/standard_fonts",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/standard_fonts")),
|
|
||||||
preprocessHTML("web/viewer.html", defines).pipe(
|
preprocessHTML("web/viewer.html", defines).pipe(
|
||||||
gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")
|
gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")
|
||||||
),
|
),
|
||||||
@ -1338,24 +1316,12 @@ gulp.task(
|
|||||||
{ base: "web/" }
|
{ base: "web/" }
|
||||||
)
|
)
|
||||||
.pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")),
|
.pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")),
|
||||||
gulp
|
createCMapBundle().pipe(
|
||||||
.src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], {
|
gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/cmaps")
|
||||||
base: "external/bcmaps",
|
),
|
||||||
})
|
createStandardFontBundle().pipe(
|
||||||
.pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/cmaps")),
|
gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/standard_fonts")
|
||||||
gulp
|
),
|
||||||
.src(
|
|
||||||
[
|
|
||||||
"external/standard_fonts/*.pfb",
|
|
||||||
"external/standard_fonts/*.ttf",
|
|
||||||
"external/standard_fonts/LICENSE_FOXIT",
|
|
||||||
"external/standard_fonts/LICENSE_LIBERATION",
|
|
||||||
],
|
|
||||||
{
|
|
||||||
base: "external/standard_fonts",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "web/standard_fonts")),
|
|
||||||
|
|
||||||
preprocessHTML("web/viewer.html", defines).pipe(
|
preprocessHTML("web/viewer.html", defines).pipe(
|
||||||
gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")
|
gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user