mirror of
https://github.com/bitwarden/browser
synced 2026-01-21 20:03:43 +00:00
* Enable cross-compilation and packaging of Windows Appx from macOS * Consolidate cargo build execution into a single function in native build script * Install cargo-xwin when needed * Install Appx tools when needed * Consolidate command execution into a single function in native build script * Only include the native node modules for the appropriate platform electron-builder's globs interact strangely, so we can't exclude all the .node files in the global config and then include the platform-specific files in the platform configuration. * Always copy Rust binaries to dist folder * Log source and destination when copying files * Update copyright * Match Electron version in Beta build
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
/* eslint-disable no-console */
|
|
/** @import { BeforePackContext } from 'app-builder-lib' */
|
|
exports.default = run;
|
|
|
|
/**
|
|
* @param {BeforePackContext} context
|
|
*/
|
|
async function run(context) {
|
|
console.log("## before pack");
|
|
console.log("Stripping .node files that don't belong to this platform...");
|
|
removeExtraNodeFiles(context);
|
|
}
|
|
|
|
/**
|
|
* Removes Node files for platforms besides the current platform being packaged.
|
|
*
|
|
* @param {BeforePackContext} context
|
|
*/
|
|
function removeExtraNodeFiles(context) {
|
|
// When doing cross-platform builds, due to electron-builder limitiations,
|
|
// .node files for other platforms may be generated and unpacked, so we
|
|
// remove them manually here before signing and distributing.
|
|
const packagerPlatform = context.packager.platform.nodeName;
|
|
const platforms = ["darwin", "linux", "win32"];
|
|
const fileFilter = context.packager.info._configuration.files[0].filter;
|
|
for (const platform of platforms) {
|
|
if (platform != packagerPlatform) {
|
|
fileFilter.push(`!node_modules/@bitwarden/desktop-napi/desktop_napi.${platform}-*.node`);
|
|
}
|
|
}
|
|
}
|