tutanota/buildSrc/prepareMobileBuild.js
wrd cac63f9c9b Remove old logo images that were still stored.
Updated the mobile build to not remove images in the images folder.

Close #8842
2025-05-15 11:36:46 +02:00

41 lines
1.2 KiB
JavaScript

import fs from "node:fs"
import { program } from "commander"
import { glob } from "glob"
import { fileURLToPath } from "node:url"
import "zx/globals"
if (process.argv[1] === fileURLToPath(import.meta.url)) {
program.usage("make|dist").arguments("<target>").action(prepareMobileBuild).parse(process.argv)
}
/**
* Removes source maps, icons, HTML files which are not needed for mobile apps.
*/
export async function prepareMobileBuild(buildType, app) {
console.log("prepare mobile build for build type", buildType)
let prefix
if (["dist", "make"].includes(buildType)) {
prefix = app === "mail" ? "build/" : "build-calendar-app/"
} else {
throw new Error("Unknown build type " + buildType)
}
const wasmpath = prefix + "wasm"
if (fs.existsSync(wasmpath)) {
console.log("unlinking ", wasmpath)
fs.rmSync(wasmpath, { force: true, recursive: true })
}
const maps = glob.sync(prefix + "*.js.map")
for (let file of maps) {
console.log("unlinking ", file)
fs.unlinkSync(file)
}
const indexHtmlPath = prefix + "index.html"
if (fs.existsSync(indexHtmlPath)) {
fs.unlinkSync(indexHtmlPath)
console.log("rm ", indexHtmlPath)
} else {
console.log("no file at", indexHtmlPath)
}
}