-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from caorushizi/fix/adblocker
Fix/adblocker
- Loading branch information
Showing
35 changed files
with
1,406 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { dev, build, release } from "./scripts/index.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,145 @@ | ||
export const external = [ | ||
import { Configuration } from "electron-builder"; | ||
import { Env, mainResolve } from "./utils"; | ||
import esbuild from "esbuild"; | ||
|
||
const external = [ | ||
"electron", | ||
"nock", | ||
"aws-sdk", | ||
"mock-aws-s3", | ||
"@cliqz/adblocker-electron-preload", | ||
"node-pty", | ||
"better-sqlite3", | ||
]; | ||
|
||
function getConfig(): esbuild.BuildOptions { | ||
const env = Env.getInstance().env; | ||
return { | ||
bundle: true, | ||
sourcemap: process.env.NODE_ENV === "development", | ||
external, | ||
define: | ||
process.env.NODE_ENV === "development" | ||
? { | ||
// 开发环境中二进制可执行文件的路径 | ||
__bin__: `"${mainResolve("app/bin").replace(/\\/g, "\\\\")}"`, | ||
} | ||
: { | ||
...env, | ||
"process.env.NODE_ENV": '"production"', | ||
}, | ||
outdir: mainResolve("app/build/main"), | ||
loader: { ".png": "file" }, | ||
minify: process.env.NODE_ENV === "production", | ||
}; | ||
} | ||
|
||
function buildOptions( | ||
entry: string, | ||
platform: esbuild.Platform, | ||
target: string, | ||
): esbuild.BuildOptions { | ||
return { | ||
...getConfig(), | ||
entryPoints: [mainResolve(entry)], | ||
platform: platform, | ||
target: [target], | ||
}; | ||
} | ||
|
||
export function browserOptions(entry: string): esbuild.BuildOptions { | ||
return buildOptions(entry, "browser", "chrome89"); | ||
} | ||
|
||
export function nodeOptions(entry: string): esbuild.BuildOptions { | ||
return buildOptions(entry, "node", "node16.13"); | ||
} | ||
|
||
export function getReleaseConfig(): Configuration { | ||
return { | ||
productName: process.env.APP_NAME, | ||
buildVersion: process.env.APP_VERSION, | ||
appId: process.env.APP_ID, | ||
copyright: process.env.APP_COPYRIGHT, | ||
artifactName: "${productName}-setup-${arch}-${buildVersion}.${ext}", | ||
// FIXME: 这里屏蔽 node-pty 自动重构,因为会导致打包失败 | ||
npmRebuild: false, | ||
directories: { | ||
output: "./release", | ||
}, | ||
asarUnpack: [ | ||
"**/better-sqlite3/build/Release/*.node", | ||
"**/node-pty/build/Release/**", | ||
], | ||
files: [ | ||
{ | ||
from: "./build", | ||
to: "./", | ||
}, | ||
"./package.json", | ||
], | ||
extraResources: [ | ||
{ | ||
from: "./app/plugin", | ||
to: "plugin", | ||
}, | ||
{ | ||
from: "./app/bin/", | ||
to: "bin", | ||
}, | ||
], | ||
win: { | ||
icon: "../assets/icon.ico", | ||
target: [ | ||
{ | ||
target: "nsis", | ||
arch: ["x64"], | ||
}, | ||
], | ||
}, | ||
dmg: { | ||
contents: [ | ||
{ | ||
x: 410, | ||
y: 150, | ||
type: "link", | ||
path: "/Applications", | ||
}, | ||
{ | ||
x: 130, | ||
y: 150, | ||
type: "file", | ||
}, | ||
], | ||
}, | ||
mac: { | ||
icon: "../assets/icon.icns", | ||
target: { | ||
target: "dmg", | ||
arch: ["x64"], | ||
}, | ||
}, | ||
linux: { | ||
category: "Utility", | ||
icon: "../assets/icon.icns", | ||
maintainer: "caorushizi <[email protected]>", | ||
target: { | ||
target: "deb", | ||
arch: ["x64"], | ||
}, | ||
}, | ||
nsis: { | ||
oneClick: true, | ||
allowElevation: true, | ||
allowToChangeInstallationDirectory: false, | ||
installerIcon: "", | ||
uninstallerIcon: "", | ||
installerHeaderIcon: "", | ||
createDesktopShortcut: true, | ||
createStartMenuShortcut: true, | ||
shortcutName: "", | ||
include: "", | ||
script: "", | ||
}, | ||
}; | ||
} |
Oops, something went wrong.