config asar when package

This commit is contained in:
an-lee
2024-03-01 10:02:00 +08:00
parent 288157c92f
commit 240c9d7e89
4 changed files with 27 additions and 9 deletions

View File

@@ -9,7 +9,11 @@ import os from "os";
const config = {
packagerConfig: {
asar: false,
asar: {
// Binary files won't work in asar, so we need to unpack them
unpackDir:
"{.vite/build/lib,.vite/build/samples,node_modules/ffmpeg-static,node_modules/@andrkrn/ffprobe-static}",
},
icon: "./assets/icon",
name: "Enjoy",
executableName: "enjoy",
@@ -79,6 +83,10 @@ const config = {
},
],
}),
{
name: "@electron-forge/plugin-auto-unpack-natives",
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
// new FusesPlugin({

View File

@@ -6,13 +6,18 @@ import log from "@main/logger";
import path from "path";
import fs from "fs-extra";
import settings from "./settings";
import url from 'url';
import url from "url";
/*
* ffmpeg and ffprobe bin file will be in /app.asar.unpacked instead of /app.asar
* the /samples folder is also in /app.asar.unpacked
*/
Ffmpeg.setFfmpegPath(ffmpegPath.replace("app.asar", "app.asar.unpacked"));
Ffmpeg.setFfprobePath(ffprobePath.replace("app.asar", "app.asar.unpacked"));
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Ffmpeg.setFfmpegPath(ffmpegPath);
Ffmpeg.setFfprobePath(ffprobePath);
const __dirname = path
.dirname(__filename)
.replace("app.asar", "app.asar.unpacked");
const logger = log.scope("ffmpeg");
export default class FfmpegWrapper {

View File

@@ -5,10 +5,15 @@ import { WHISPER_MODELS_OPTIONS, PROCESS_TIMEOUT } from "@/constants";
import { exec, spawn } from "child_process";
import fs from "fs-extra";
import log from "@main/logger";
import url from 'url';
import url from "url";
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/*
* whipser bin file will be in /app.asar.unpacked instead of /app.asar
*/
const __dirname = path
.dirname(__filename)
.replace("app.asar", "app.asar.unpacked");
const logger = log.scope("whisper");

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"module": "ESNext",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,