Skip to content

[gulpfile.js] Use the regular defines in the preprocessCSS function #14682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions external/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function preprocess(inFilename, outFilename, defines) {
}
exports.preprocess = preprocess;

function preprocessCSS(mode, source, destination) {
function preprocessCSS(inFilename, outFilename, defines) {
function hasPrefixedMozcentral(line) {
return /(^|\W)-(ms|o|webkit)-\w/.test(line);
}
Expand Down Expand Up @@ -262,16 +262,16 @@ function preprocessCSS(mode, source, destination) {
return lines.join("\n");
}

if (!mode) {
throw new Error("Invalid CSS preprocessor mode");
if (!defines) {
throw new Error("Missing CSS preprocessor defines.");
}

let content = fs.readFileSync(source, "utf8").toString();
content = expandImports(content, source);
if (mode === "mozcentral") {
let content = fs.readFileSync(inFilename, "utf8").toString();
content = expandImports(content, inFilename);
if (defines.MOZCENTRAL) {
content = removePrefixed(content, hasPrefixedMozcentral);
}
fs.writeFileSync(destination, content);
fs.writeFileSync(outFilename, content);
}
exports.preprocessCSS = preprocessCSS;

Expand Down
16 changes: 8 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,9 @@ gulp.task("cmaps", function (done) {
done();
});

function preprocessCSS(source, mode, defines) {
function preprocessCSS(source, defines) {
const outName = getTempFile("~preprocess", ".css");
builder.preprocessCSS(mode, source, outName);
builder.preprocessCSS(source, outName, defines);
let out = fs.readFileSync(outName).toString();
fs.unlinkSync(outName);

Expand Down Expand Up @@ -848,7 +848,7 @@ function buildGeneric(defines, dir) {
createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")),

preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")),
preprocessCSS("web/viewer.css", "generic", defines)
preprocessCSS("web/viewer.css", defines)
.pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)]))
.pipe(gulp.dest(dir + "web")),

Expand Down Expand Up @@ -924,7 +924,7 @@ function buildComponents(defines, dir) {
return merge([
createComponentsBundle(defines).pipe(gulp.dest(dir)),
gulp.src(COMPONENTS_IMAGES).pipe(gulp.dest(dir + "images")),
preprocessCSS("web/pdf_viewer.css", "components", defines)
preprocessCSS("web/pdf_viewer.css", defines)
.pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)]))
.pipe(gulp.dest(dir)),
]);
Expand Down Expand Up @@ -1014,7 +1014,7 @@ function buildMinified(defines, dir) {
createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")),

preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")),
preprocessCSS("web/viewer.css", "minified", defines)
preprocessCSS("web/viewer.css", defines)
.pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)]))
.pipe(gulp.dest(dir + "web")),

Expand Down Expand Up @@ -1244,7 +1244,7 @@ gulp.task(
preprocessHTML("web/viewer.html", defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")
),
preprocessCSS("web/viewer.css", "mozcentral", defines)
preprocessCSS("web/viewer.css", defines)
.pipe(
postcss([
autoprefixer({
Expand Down Expand Up @@ -1336,7 +1336,7 @@ gulp.task(
preprocessHTML("web/viewer.html", defines).pipe(
gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")
),
preprocessCSS("web/viewer.css", "chrome", defines)
preprocessCSS("web/viewer.css", defines)
.pipe(
postcss([autoprefixer({ overrideBrowserslist: ["Chrome >= 73"] })])
)
Expand Down Expand Up @@ -1871,7 +1871,7 @@ gulp.task("dev-css", function createDevCSS() {
return merge([
gulp.src("web/images/*", { base: "web/" }).pipe(gulp.dest(cssDir)),

preprocessCSS("web/viewer.css", "generic", defines)
preprocessCSS("web/viewer.css", defines)
.pipe(
postcss([autoprefixer({ overrideBrowserslist: ["last 2 versions"] })])
)
Expand Down