Skip to content
Merged
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
53 changes: 53 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ const removeDirs = (base, filterFn) => {
}
};

const deleteFiles = (basePath, filenames) => {
filenames.forEach(filename => {
const filePath = path.join(basePath, filename);
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}
});
};

try {
console.log(' Building Moonfin for webOS...\n');

Expand All @@ -43,6 +52,50 @@ try {
const localeDir = path.join('dist', 'node_modules', 'ilib', 'locale');
removeDirs(localeDir, (name) => !name.startsWith('en'));

// Root-level files: phone, currency, unit, address, astronomy data
console.log('\n Removing unused ilib data files...');
const nonEngLocalefiles = ([
'currency.json',
'numplan.json',
'emergency.json',
'unitfmt.json',
'phoneloc.json',
'phonefmt.json',
'iddarea.json',
'idd.json',
'mnc.json',
'address.json',
'addressres.json',
'astro.json',
'pseudomap.json',
'collation.json',
'countries.json',
'nativecountries.json',
'ctrynames.json',
'ctryreverse.json',
'name.json',
'lang2charset.json',
'ccc.json'
]);
deleteFiles(path.join('dist', 'node_modules', 'ilib', 'locale'), nonEngLocalefiles);

// Remove Deseret script locale (historic/obsolete)
fs.rmSync(path.join('dist', 'node_modules', 'ilib', 'locale', 'en', 'Dsrt'), {recursive: true, force: true});

// Strip bulky files from en/ regional subdirs (keep only sysres, dateformats, list, localeinfo, plurals)
console.log('\n Removing non-essential files from en/ regional locale dirs...');
deleteFiles(path.join('dist', 'node_modules', 'ilib', 'locale', 'en'), nonEngLocalefiles);

// Remove unused font weights to reduce size
console.log('\n Removing unused font weights...');
const fontFiles = ([
'MuseoSans-Thin.ttf',
'MuseoSans-BlackItalic.ttf',
'MuseoSans-BoldItalic.ttf',
'MuseoSans-MediumItalic.ttf'
]);
deleteFiles(path.join('dist', 'node_modules', '@enact', 'sandstone', 'fonts', 'MuseoSans'), fontFiles);

// Package into IPK
console.log('\n Creating IPK package...');
fs.mkdirSync('build', {recursive: true});
Expand Down