- Author: Ganesh Rathinavel
- License: MIT
- Website URL: https://github.com/ganeshrvel/tutorial-electron-afterpack-script
- Repo URL: https://github.com/ganeshrvel/tutorial-electron-afterpack-script
- Contacts: ganeshrvel@outlook.com
There isn't much information available on Electron Builder AfterPack configuration. I have created a sample code which cleans the junk locale directories from the packaged electron app.
I have spent a significant amount of time researching how to get this done. This was originally implemented inside OpenMTP - Advanced Android File Transfer Application for macOS.
- Add the below lines inside your package.json file
"build": {
"afterPack": "./internals/scripts/AfterPack.js"
}
- Create a file ./internals/scripts/AfterPack.js and add the below code
'use strict';
const path = require('path');
const glob = require('glob');
const fs = require('fs-extra');
exports.default = context => {
const lprojRegEx = /(en)\.lproj/g;
const APP_NAME = context.packager.appInfo.productFilename;
const APP_OUT_DIR = context.appOutDir;
const PLATFORM = context.packager.platform.name;
const cwd = path.join(`${APP_OUT_DIR}`, `${APP_NAME}.app/Contents/Resources`);
const lproj = glob.sync('*.lproj', { cwd });
const _promises = [];
switch (PLATFORM) {
case 'mac':
lproj.forEach(dir => {
if (!lprojRegEx.test(dir)) {
_promises.push(fs.remove(path.join(cwd, dir)));
}
});
break;
default:
break;
}
return Promise.all(_promises);
};
- Fork the repo and create your branch from master.
- Ensure that the changes pass linting.
- Update the documentation if needed.
- Make sure your code lints.
- Issue a pull request!
When you submit code changes, your submissions are understood to be under the same MIT License that covers the project. Feel free to contact the maintainers if that's a concern.
Help me keep the app FREE and open for all. Paypal me: paypal.me/ganeshrvel
Please feel free to contact me at ganeshrvel@outlook.com
- OpenMTP - Advanced Android File Transfer Application for macOS
- Tutorial Series by Ganesh Rathinavel
- npm: electron-root-path
- Electron React Redux Advanced Boilerplate
tutorial-electron-afterpack-script is released under MIT License.
Copyright © 2018-Present Ganesh Rathinavel