Skip to content

Commit

Permalink
Use modern build for ipad os 15 and macos 11
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Aug 14, 2024
1 parent 6754b88 commit 0abf5ed
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions build-scripts/gulp/entry-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@ import { htmlMinifierOptions, terserOptions } from "../bundle.cjs";
import env from "../env.cjs";
import paths from "../paths.cjs";

// Regex to match iPadOS >= 15 and macOS >= 11 (app web view) because browserlist is not capable of this
const ipadMacOSRegex =
/\b(iPadOS\s*(1[5-9]|[2-9]\d)(?:\.\d+)?(?:\.\d+)?)|(macOS\s*(1[1-9]|[2-9]\d)(?:\.\d+)?(?:\.\d+)?)\b/;

const renderTemplate = (templateFile, data = {}) => {
const compiled = template(
fs.readFileSync(templateFile, { encoding: "utf-8" })
);

const userAgentRegex = getUserAgentRegex({
env: "modern",
allowHigherVersions: true,
mobileToDesktop: true,
throwOnMissing: true,
});

return compiled({
...data,
useRollup: env.useRollup(),
useWDS: env.useWDS(),
modernRegex: getUserAgentRegex({
env: "modern",
allowHigherVersions: true,
mobileToDesktop: true,
throwOnMissing: true,
}).toString(),
modernRegex: new RegExp(
`(${ipadMacOSRegex.source})|(${userAgentRegex.source})`
).toString(),
// Resolve any child/nested templates relative to the parent and pass the same data
renderTemplate: (childTemplate) =>
renderTemplate(
Expand Down

0 comments on commit 0abf5ed

Please sign in to comment.