mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(nx/desktop): use custom electron-rebuild script
This commit is contained in:
parent
a0c1bdde88
commit
b64521d250
@ -53,7 +53,7 @@
|
|||||||
"cache": true,
|
"cache": true,
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"default": {
|
"default": {
|
||||||
"command": "electron-rebuild -f dist/main.js -m dist",
|
"command": "cross-env DEBUG=* tsx scripts/rebuild.ts",
|
||||||
"cwd": "{projectRoot}"
|
"cwd": "{projectRoot}"
|
||||||
},
|
},
|
||||||
"nixos": {
|
"nixos": {
|
||||||
|
35
apps/desktop/scripts/rebuild.ts
Normal file
35
apps/desktop/scripts/rebuild.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* @module
|
||||||
|
*
|
||||||
|
* This script is used internally by the `rebuild-deps` target of the `desktop`. Normally we could use
|
||||||
|
* `electron-rebuild` CLI directly, but it would rebuild the monorepo-level dependencies and breaks
|
||||||
|
* the server build (and it doesn't expose a CLI option to override this).
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
import { dirname, join } from "path";
|
||||||
|
import rebuild from "@electron/rebuild"
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
|
||||||
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const rootDir = join(scriptDir, "..");
|
||||||
|
|
||||||
|
function getElectronVersion() {
|
||||||
|
const packageJsonPath = join(rootDir, "package.json");
|
||||||
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
||||||
|
return packageJson.devDependencies.electron;
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const distDir = join(rootDir, "dist");
|
||||||
|
|
||||||
|
rebuild({
|
||||||
|
// We force the project root path to avoid electron-rebuild from rebuilding the monorepo-level dependency and breaking the server.
|
||||||
|
projectRootPath: distDir,
|
||||||
|
buildPath: distDir,
|
||||||
|
force: true,
|
||||||
|
electronVersion: getElectronVersion(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
Loading…
x
Reference in New Issue
Block a user