Skip to content

Commit

Permalink
Merge pull request #11869 from Snuffleupagus/gulpfile-cleanup
Browse files Browse the repository at this point in the history
Various smaller clean-up in `gulpfile.js`
  • Loading branch information
timvandermeij committed May 3, 2020
2 parents d822578 + a9e7798 commit 2711f4b
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,7 @@ function replaceJSRootName(amdName, jsName) {
);
}

function createBundle(defines) {
console.log();
console.log("### Bundling files into pdf.js");

function createMainBundle(defines) {
var mainAMDName = "pdfjs-dist/build/pdf";
var mainOutputName = "pdf.js";

Expand All @@ -309,12 +306,14 @@ function createBundle(defines) {
libraryTarget: "umd",
umdNamedDefine: true,
});
var mainOutput = gulp
return gulp
.src("./src/pdf.js")
.pipe(webpack2Stream(mainFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceJSRootName(mainAMDName, "pdfjsLib"));
}

function createWorkerBundle(defines) {
var workerAMDName = "pdfjs-dist/build/pdf.worker";
var workerOutputName = "pdf.worker.js";

Expand All @@ -324,13 +323,11 @@ function createBundle(defines) {
libraryTarget: "umd",
umdNamedDefine: true,
});

var workerOutput = gulp
return gulp
.src("./src/pdf.worker.js")
.pipe(webpack2Stream(workerFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceJSRootName(workerAMDName, "pdfjsWorker"));
return merge([mainOutput, workerOutput]);
}

function createWebBundle(defines) {
Expand Down Expand Up @@ -677,13 +674,6 @@ gulp.task("cmaps", function (done) {
done();
});

gulp.task(
"bundle",
gulp.series("buildnumber", function () {
return createBundle(DEFINES).pipe(gulp.dest(BUILD_DIR));
})
);

function preprocessCSS(source, mode, defines, cleanup) {
var outName = getTempFile("~preprocess", ".css");
builder.preprocessCSS(mode, source, outName);
Expand Down Expand Up @@ -713,7 +703,8 @@ function buildGeneric(defines, dir) {
rimraf.sync(dir);

return merge([
createBundle(defines).pipe(gulp.dest(dir + "build")),
createMainBundle(defines).pipe(gulp.dest(dir + "build")),
createWorkerBundle(defines).pipe(gulp.dest(dir + "build")),
createWebBundle(defines).pipe(gulp.dest(dir + "web")),
gulp.src(COMMON_WEB_FILES, { base: "web/" }).pipe(gulp.dest(dir + "web")),
gulp.src("LICENSE").pipe(gulp.dest(dir)),
Expand Down Expand Up @@ -847,7 +838,8 @@ gulp.task(
rimraf.sync(MINIFIED_DIR);

return merge([
createBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "build")),
createMainBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "build")),
createWorkerBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "build")),
createWebBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "web")),
createImageDecodersBundle(
builder.merge(defines, { IMAGE_DECODERS: true })
Expand Down Expand Up @@ -1007,7 +999,12 @@ gulp.task(
];

return merge([
createBundle(defines).pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")),
createMainBundle(defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")
),
createWorkerBundle(defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")
),
createWebBundle(defines).pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")),
gulp
.src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" })
Expand Down Expand Up @@ -1062,7 +1059,12 @@ gulp.task(
var version = getVersionJSON().version;

return merge([
createBundle(defines).pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "build")),
createMainBundle(defines).pipe(
gulp.dest(CHROME_BUILD_CONTENT_DIR + "build")
),
createWorkerBundle(defines).pipe(
gulp.dest(CHROME_BUILD_CONTENT_DIR + "build")
),
createWebBundle(defines).pipe(
gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")
),
Expand Down

0 comments on commit 2711f4b

Please sign in to comment.