feat/ Add electron-packager scripts
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
|||||||
/dist
|
/dist
|
||||||
/tmp
|
/tmp
|
||||||
/out-tsc
|
/out-tsc
|
||||||
|
/app-builds
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -28,12 +28,21 @@ npm install
|
|||||||
## To build for development
|
## To build for development
|
||||||
|
|
||||||
**in a terminal window** -> npm start
|
**in a terminal window** -> npm start
|
||||||
**in another terminal window** -> npm run electron
|
**in another terminal window** -> npm run electron:serve
|
||||||
|
|
||||||
The code for this is managed at `main.js`. In this sample, the app runs with a simple Electron window.
|
The code for this is managed at `main.js`. In this sample, the app runs with a simple Electron window.
|
||||||
By default, Developer tools is opened. You can unactivate it by uncomment `win.webContents.openDevTools();` in `main.js`.
|
By default, Developer tools is opened. You can unactivate it by uncomment `win.webContents.openDevTools();` in `main.js`.
|
||||||
|
|
||||||
## To build for production
|
## To build for production
|
||||||
|
|
||||||
npm run build
|
- npm run electron:dist
|
||||||
npm run electron dist
|
|
||||||
|
You can find your builted files in the /dist directory.
|
||||||
|
|
||||||
|
## Included Commands
|
||||||
|
|
||||||
|
- `npm run electron:linux` - builds your application and creates an app consumable on linux systems.
|
||||||
|
- `npm run electron:windows` - On a Windows OS, builds your application and creates an app consumable in windows 32/64 bit systems.
|
||||||
|
- `npm run electron:mac` - On a MAC OS, builds your application and generates a `.app` file of your application that can be run on mac .
|
||||||
|
|
||||||
|
**Your executable is optimised. There are only the files of /dist directory in the executable generated.**
|
||||||
9
main.js
9
main.js
@@ -20,11 +20,12 @@ function createWindow() {
|
|||||||
height: size.height
|
height: size.height
|
||||||
});
|
});
|
||||||
|
|
||||||
let url = 'http://localhost:4200';
|
let url = 'file://' + __dirname + '/index.html';
|
||||||
let Args = process.argv.slice(2);
|
let Args = process.argv.slice(1);
|
||||||
|
|
||||||
Args.forEach(function (val) {
|
Args.forEach(function (val) {
|
||||||
if (val === "dist") {
|
if (val === "--serve") {
|
||||||
url = 'file://' + __dirname + '/dist/index.html'
|
url = 'http://localhost:4200'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
16
package.json
16
package.json
@@ -7,7 +7,7 @@
|
|||||||
"name": "Maxime GRIS",
|
"name": "Maxime GRIS",
|
||||||
"email": "maxime.gris@gmail.com"
|
"email": "maxime.gris@gmail.com"
|
||||||
},
|
},
|
||||||
"keywords" : [
|
"keywords": [
|
||||||
"angular",
|
"angular",
|
||||||
"electron",
|
"electron",
|
||||||
"typescript",
|
"typescript",
|
||||||
@@ -18,12 +18,15 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build && copyfiles main.js dist",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e",
|
"e2e": "ng e2e",
|
||||||
"electron": "electron .",
|
"electron:serve": "electron . --serve",
|
||||||
"electron dist": "electron main.js"
|
"electron:dist": "npm run build && electron dist/main.js",
|
||||||
|
"electron:linux": "npm run build && copyfiles package.json dist && electron-packager dist --overwrite --platform=linux --arch=x64 --asar=true --out=app-builds",
|
||||||
|
"electron:windows": "npm run build && copyfiles package.json dist && electron-packager dist --overwrite --platform=win32 --arch=ia32 --asar=false --out=app-builds",
|
||||||
|
"electron:mac": "npm run build && copyfiles package.json dist && electron-packager . --overwrite --platform=darwin --arch=x64 --asar=true --out=app-builds"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "~4.0.0",
|
"@angular/common": "~4.0.0",
|
||||||
@@ -44,15 +47,18 @@
|
|||||||
"@types/jasmine": "2.5.38",
|
"@types/jasmine": "2.5.38",
|
||||||
"@types/node": "~6.0.60",
|
"@types/node": "~6.0.60",
|
||||||
"codelyzer": "~2.0.0",
|
"codelyzer": "~2.0.0",
|
||||||
|
"copyfiles": "^1.2.0",
|
||||||
|
"electron": "1.6.2",
|
||||||
|
"electron-packager": "~8.6.0",
|
||||||
"electron-prebuilt": "~1.4.13",
|
"electron-prebuilt": "~1.4.13",
|
||||||
"jasmine-core": "~2.5.2",
|
"jasmine-core": "~2.5.2",
|
||||||
"jasmine-spec-reporter": "~3.2.0",
|
"jasmine-spec-reporter": "~3.2.0",
|
||||||
"karma": "~1.4.1",
|
"karma": "~1.4.1",
|
||||||
"karma-chrome-launcher": "~2.0.0",
|
"karma-chrome-launcher": "~2.0.0",
|
||||||
"karma-cli": "~1.0.1",
|
"karma-cli": "~1.0.1",
|
||||||
|
"karma-coverage-istanbul-reporter": "~0.2.0",
|
||||||
"karma-jasmine": "~1.1.0",
|
"karma-jasmine": "~1.1.0",
|
||||||
"karma-jasmine-html-reporter": "~0.2.2",
|
"karma-jasmine-html-reporter": "~0.2.2",
|
||||||
"karma-coverage-istanbul-reporter": "~0.2.0",
|
|
||||||
"protractor": "~5.1.0",
|
"protractor": "~5.1.0",
|
||||||
"ts-node": "~2.0.0",
|
"ts-node": "~2.0.0",
|
||||||
"tslint": "~4.5.0",
|
"tslint": "~4.5.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user