mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
feat(forge): remove unused locales
This commit is contained in:
parent
825c2c1fe9
commit
23c45ee219
@ -1,5 +1,6 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
const { LOCALES } = require("@triliumnext/commons");
|
||||
|
||||
const ELECTRON_FORGE_DIR = __dirname;
|
||||
|
||||
@ -141,6 +142,35 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
hooks: {
|
||||
// Remove unused locales from the packaged app to save some space.
|
||||
postPackage(_, packageResult) {
|
||||
const localesToKeep = LOCALES
|
||||
.filter(locale => !locale.contentOnly)
|
||||
.map(locale => locale.electronLocale.replace("_", "-"));
|
||||
|
||||
for (const outputPath of packageResult.outputPaths) {
|
||||
const localesDir = path.join(outputPath, 'locales');
|
||||
|
||||
if (!fs.existsSync(localesDir)) {
|
||||
console.log('No locales directory found. Skipping cleanup.');
|
||||
return;
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(localesDir);
|
||||
|
||||
for (const file of files) {
|
||||
const localeName = path.basename(file, ".pak");
|
||||
if (localesToKeep.includes(localeName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(`Removing unused locale file: ${file}`);
|
||||
const filePath = path.join(localesDir, file);
|
||||
fs.unlinkSync(filePath);
|
||||
}
|
||||
}
|
||||
},
|
||||
// Gather all the artifacts produced by the makers and copy them to a common upload directory.
|
||||
postMake(_, makeResults) {
|
||||
const outputDir = path.join(__dirname, "..", "upload");
|
||||
fs.mkdirpSync(outputDir);
|
||||
|
@ -24,6 +24,9 @@
|
||||
"references": [
|
||||
{
|
||||
"path": "../server/tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/commons/tsconfig.lib.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -6,6 +6,9 @@
|
||||
{
|
||||
"path": "../server"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/commons"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user