Skip to content

Commit

Permalink
feat/ Add electron-packager scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime GRIS committed Apr 3, 2017
1 parent 9a983c1 commit 57891dc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5,394 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/dist
/tmp
/out-tsc
/app-builds

# dependencies
/node_modules
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ npm install
## To build for development

**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.
By default, Developer tools is opened. You can unactivate it by uncomment `win.webContents.openDevTools();` in `main.js`.

## 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 changes: 5 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ function createWindow() {
height: size.height
});

let url = 'http://localhost:4200';
let Args = process.argv.slice(2);
let url = 'file://' + __dirname + '/index.html';
let Args = process.argv.slice(1);

Args.forEach(function (val) {
if (val === "dist") {
url = 'file://' + __dirname + '/dist/index.html'
if (val === "--serve") {
url = 'http://localhost:4200'
}
});

Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "Maxime GRIS",
"email": "maxime.gris@gmail.com"
},
"keywords" : [
"keywords": [
"angular",
"electron",
"typescript",
Expand All @@ -18,12 +18,15 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build": "ng build && copyfiles main.js dist",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "electron .",
"electron dist": "electron main.js"
"electron:serve": "electron . --serve",
"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": {
"@angular/common": "~4.0.0",
Expand All @@ -44,15 +47,18 @@
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"copyfiles": "^1.2.0",
"electron": "1.6.2",
"electron-packager": "~8.6.0",
"electron-prebuilt": "~1.4.13",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "~0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "~0.2.2",
"karma-coverage-istanbul-reporter": "~0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
Expand Down
Loading

0 comments on commit 57891dc

Please sign in to comment.