Add auto bundle script
This commit is contained in:
parent
8b29654fdf
commit
4f6b1ebbf2
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,6 +42,7 @@ node_modules/
|
||||
jspm_packages/
|
||||
build/
|
||||
out/
|
||||
bundle/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
55
config/electron.forge.config.js
Normal file
55
config/electron.forge.config.js
Normal file
@ -0,0 +1,55 @@
|
||||
const FS = require("fs");
|
||||
const Path = require("path");
|
||||
const minimist = require("minimist");
|
||||
|
||||
const args = minimist(process.argv.slice(2));
|
||||
|
||||
const PackageJSON = JSON.parse(
|
||||
FS.readFileSync(Path.join(__dirname, "../package.json"))
|
||||
);
|
||||
|
||||
const Config = {
|
||||
"name": PackageJSON.name,
|
||||
"productName": PackageJSON.name,
|
||||
"version": PackageJSON.version,
|
||||
"description": PackageJSON.description,
|
||||
"main": "./Electron.js",
|
||||
"scripts": {
|
||||
"start": "electron-forge start",
|
||||
"package": "electron-forge package",
|
||||
"make": "electron-forge make",
|
||||
"publish": "electron-forge publish",
|
||||
"lint": "echo \"No linting configured\""
|
||||
},
|
||||
"keywords": PackageJSON.keywords,
|
||||
"author": {
|
||||
"name": PackageJSON.author,
|
||||
"email": "mrkbear@qq.com"
|
||||
},
|
||||
"license": PackageJSON.license,
|
||||
"config": {
|
||||
"forge": {
|
||||
"packagerConfig": {},
|
||||
"makers": [
|
||||
{
|
||||
"name": "@electron-forge/maker-zip",
|
||||
"platforms": [
|
||||
"darwin"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"detect-port": PackageJSON.dependencies["detect-port"],
|
||||
"express": PackageJSON.dependencies["express"],
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "^6.0.0-beta.63",
|
||||
"@electron-forge/maker-zip": "^6.0.0-beta.63",
|
||||
"electron": PackageJSON.devDependencies.electron
|
||||
}
|
||||
}
|
||||
|
||||
FS.writeFileSync(Path.join(Path.resolve("./"), args.out ?? "./", "./package.json"), JSON.stringify(Config, null, 4));
|
@ -25,6 +25,7 @@ module.exports = (env) => {
|
||||
}
|
||||
},
|
||||
|
||||
// externals: [nodeExternals({ allowlist: [/^(((?!electron).)*)$/] })],
|
||||
externals: [nodeExternals()],
|
||||
|
||||
module: {
|
||||
|
10
package.json
10
package.json
@ -19,17 +19,21 @@
|
||||
"run-service": "node ./build/ServiceRunner.js --run --path ./build --port 12000",
|
||||
"build-run-web": "npm run build-web & npm run build-service & npm run run-service",
|
||||
"release-run-web": "npm run release-web & npm run release-service & npm run run-service",
|
||||
"copy-fluent-icon": "fse mkdirp ./build/font-icon/ && fse emptyDir ./build/font-icon/ && fse copy ./node_modules/@fluentui/font-icons-mdl2/fonts/ ./build/font-icon/",
|
||||
"copy-fluent-icon": "fse mkdirp ./build/font-icon/ & fse emptyDir ./build/font-icon/ & fse copy ./node_modules/@fluentui/font-icons-mdl2/fonts/ ./build/font-icon/",
|
||||
"build-run-desktop-web": "npm run build-desktop-web & npm run copy-fluent-icon & npm run build-service & npm run run-service",
|
||||
"release-run-desktop-web": "npm run release-desktop-web & npm run copy-fluent-icon & npm run release-service & npm run run-service",
|
||||
"skip-electron-ci": "set ELECTRON_SKIP_BINARY_DOWNLOAD=1& npm ci",
|
||||
"build-electron": "webpack --mode development --config ./config/webpack.electron.js",
|
||||
"release-electron": "webpack --mode production --no-devtool --config ./config/webpack.electron.js",
|
||||
"electron-cache": "set ELECTRON_SKIP_BINARY_DOWNLOAD=& set ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/& set ELECTRON_CUSTOM_DIR={{ version }}& node ./node_modules/electron/install.js",
|
||||
"electron": "set LIVING_TOGETHER_BASE_PATH=./build& npx electron ./build/Electron.js",
|
||||
"electron": "set LIVING_TOGETHER_BASE_PATH=./build& set LIVING_TOGETHER_WEB_PATH=/& npx electron ./build/Electron.js",
|
||||
"hmr-electron": "npm run build-electron & set LIVING_TOGETHER_SERVICE=http://127.0.0.1:12000& npm run electron",
|
||||
"build-run-electron": "npm run build-desktop-web & npm run copy-fluent-icon & npm run build-electron & npm run electron",
|
||||
"release-run-electron": "npm run release-desktop-web & npm run copy-fluent-icon & npm run release-electron & npm run electron"
|
||||
"release-run-electron": "npm run release-desktop-web & npm run copy-fluent-icon & npm run release-electron & npm run electron",
|
||||
"copy-package-json": "fse mkdirp ./bundle/ & node ./config/electron.forge.config.js --out ./bundle",
|
||||
"copy-build-result": "fse mkdirp ./bundle/ & fse mkdirp ./build/ & fse copy ./build/ ./bundle/",
|
||||
"electron-app-ci": "cd ./bundle & npm install & cd ../",
|
||||
"gen-bundle": "fse emptyDir ./bundle/ & npm run copy-package-json & npm run electron-app-ci"
|
||||
},
|
||||
"keywords": [
|
||||
"artwork",
|
||||
|
@ -52,13 +52,13 @@ class ElectronApp {
|
||||
webPreferences: { preload }
|
||||
});
|
||||
|
||||
this.simulatorWindow.loadURL(this.serviceUrl);
|
||||
this.simulatorWindow.loadURL(this.serviceUrl + (ENV.LIVING_TOGETHER_WEB_PATH ?? "/resources/app/"));
|
||||
|
||||
this.handelSimulatorWindowBehavior();
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private handelSimulatorWindowBehavior() {
|
||||
|
@ -42,7 +42,7 @@ class Service {
|
||||
|
||||
console.log("Service: service run in port " + this.servicePort);
|
||||
|
||||
return "http://127.0.0.1:" + this.servicePort + "/";
|
||||
return "http://127.0.0.1:" + this.servicePort;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user