ref/ postinstall web & electron
This commit is contained in:
17
README.md
17
README.md
@@ -15,9 +15,8 @@ Bootstrap and package your project with Angular 6(+) and Electron (Typescript +
|
|||||||
|
|
||||||
Currently runs with:
|
Currently runs with:
|
||||||
|
|
||||||
- Angular v6.0.3
|
- Angular v6.0.6
|
||||||
- Angular-CLI v6.0.3
|
- Electron v2.0.3
|
||||||
- Electron v2.0.1
|
|
||||||
- Electron Builder v20.13.4
|
- Electron Builder v20.13.4
|
||||||
|
|
||||||
With this sample, you can :
|
With this sample, you can :
|
||||||
@@ -64,7 +63,7 @@ You can desactivate "Developer Tools" by commenting `win.webContents.openDevTool
|
|||||||
|
|
||||||
|Command|Description|
|
|Command|Description|
|
||||||
|--|--|
|
|--|--|
|
||||||
|`npm run ng:serve`| Execute the app in the browser |
|
|`npm run ng:serve:web`| Execute the app in the browser |
|
||||||
|`npm run build`| Build the app. Your built files are in the /dist folder. |
|
|`npm run build`| Build the app. Your built files are in the /dist folder. |
|
||||||
|`npm run build:prod`| Build the app with Angular aot. Your built files are in the /dist folder. |
|
|`npm run build:prod`| Build the app with Angular aot. Your built files are in the /dist folder. |
|
||||||
|`npm run electron:local`| Builds your application and start electron
|
|`npm run electron:local`| Builds your application and start electron
|
||||||
@@ -76,17 +75,9 @@ You can desactivate "Developer Tools" by commenting `win.webContents.openDevTool
|
|||||||
|
|
||||||
## Browser mode
|
## Browser mode
|
||||||
|
|
||||||
Maybe you want to execute the application in the browser (WITHOUT HOT RELOAD ACTUALLY...) ? You can do it with `npm run ng:serve`.
|
Maybe you want to execute the application in the browser with hot reload ? You can do it with `npm run ng:serve:web`.
|
||||||
Note that you can't use Electron or NodeJS native libraries in this case. Please check `providers/electron.service.ts` to watch how conditional import of electron/Native libraries is done.
|
Note that you can't use Electron or NodeJS native libraries in this case. Please check `providers/electron.service.ts` to watch how conditional import of electron/Native libraries is done.
|
||||||
|
|
||||||
## Error with nodejs third party packages
|
|
||||||
|
|
||||||
Since Angular 6 does not provide an eject anymore, you can't configure your webpack config file to import node externals.
|
|
||||||
|
|
||||||
An issue in [Angular repository](https://github.com/angular/angular-cli/issues/10681) is opened about this feature.
|
|
||||||
|
|
||||||
Please have a look at [Stack Overflow Post workaround](https://stackoverflow.com/questions/50234196/after-updating-from-angular-5-to-6-i-keep-getting-the-error-cant-resolve-timer) that may work in some cases. Or use branch [angular5](https://github.com/maximegris/angular-electron/tree/angular5) and continue to eject your configuration file.
|
|
||||||
|
|
||||||
## Branch & Packages version
|
## Branch & Packages version
|
||||||
|
|
||||||
- Angular 4 & Electron 1 : Branch [angular4](https://github.com/maximegris/angular-electron/tree/angular4)
|
- Angular 4 & Electron 1 : Branch [angular4](https://github.com/maximegris/angular-electron/tree/angular4)
|
||||||
|
|||||||
46
package.json
46
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "angular-electron",
|
"name": "angular-electron",
|
||||||
"version": "4.0.0",
|
"version": "4.1.0",
|
||||||
"description": "Angular 6 with Electron (Typescript + SASS + Hot Reload)",
|
"description": "Angular 6 with Electron (Typescript + SASS + Hot Reload)",
|
||||||
"homepage": "https://github.com/maximegris/angular-electron",
|
"homepage": "https://github.com/maximegris/angular-electron",
|
||||||
"author": {
|
"author": {
|
||||||
@@ -17,36 +17,40 @@
|
|||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "npx electron-builder install-app-deps && node postinstall",
|
"postinstall": "npm run postinstall:electron && npx electron-builder install-app-deps",
|
||||||
|
"postinstall:web": "node postinstall-web",
|
||||||
|
"postinstall:electron": "node postinstall",
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "npm-run-all -p ng:serve electron:serve",
|
"start": "npm run postinstall:electron && npm-run-all -p ng:serve electron:serve",
|
||||||
"build": "npm run electron:tsc && ng build",
|
"build": "npm run postinstall:electron && npm run electron:tsc && ng build",
|
||||||
"build:dev": "npm run build -- -c dev",
|
"build:dev": "npm run build -- -c dev",
|
||||||
"build:prod": "npm run build -- -c production",
|
"build:prod": "npm run build -- -c production",
|
||||||
"ng:serve": "ng serve -o",
|
"ng:serve": "ng serve",
|
||||||
|
"ng:serve:web": "npm run postinstall:web && ng serve -o",
|
||||||
"electron:tsc": "tsc main.ts",
|
"electron:tsc": "tsc main.ts",
|
||||||
"electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:tsc && electron . --serve",
|
"electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:tsc && electron . --serve",
|
||||||
"electron:local": "npm run build:prod && electron .",
|
"electron:local": "npm run build:prod && electron .",
|
||||||
"electron:linux": "npm run build:prod && npx electron-builder build --linux",
|
"electron:linux": "npm run build:prod && npx electron-builder build --linux",
|
||||||
"electron:windows": "npm run build:prod && npx electron-builder build --windows",
|
"electron:windows": "npm run build:prod && npx electron-builder build --windows",
|
||||||
"electron:mac": "npm run build:prod && npx electron-builder build --mac",
|
"electron:mac": "npm run build:prod && npx electron-builder build --mac",
|
||||||
"test": "ng test",
|
"test": "npm run postinstall:web && ng test",
|
||||||
"e2e": "ng e2e"
|
"e2e": "npm run postinstall:web && ng e2e"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "0.6.3",
|
"@angular-devkit/build-angular": "0.6.3",
|
||||||
"@angular/cli": "6.0.3",
|
"@angular/cli": "6.0.6",
|
||||||
"@angular/common": "6.0.3",
|
"@angular/common": "6.0.6",
|
||||||
"@angular/compiler": "6.0.3",
|
"@angular/compiler": "6.0.6",
|
||||||
"@angular/compiler-cli": "6.0.3",
|
"@angular/compiler-cli": "6.0.6",
|
||||||
"@angular/core": "6.0.3",
|
"@angular/core": "6.0.6",
|
||||||
"@angular/forms": "6.0.3",
|
"@angular/forms": "6.0.6",
|
||||||
"@angular/http": "6.0.3",
|
"@angular/http": "6.0.6",
|
||||||
"@angular/language-service": "6.0.3",
|
"@angular/language-service": "6.0.6",
|
||||||
"@angular/platform-browser": "6.0.3",
|
"@angular/platform-browser": "6.0.6",
|
||||||
"@angular/platform-browser-dynamic": "6.0.3",
|
"@angular/platform-browser-dynamic": "6.0.6",
|
||||||
"@angular/router": "6.0.3",
|
"@angular/router": "6.0.6",
|
||||||
"@ngx-translate/core": "10.0.1",
|
"@ngx-translate/core": "10.0.1",
|
||||||
"@ngx-translate/http-loader": "3.0.1",
|
"@ngx-translate/http-loader": "3.0.1",
|
||||||
"@types/jasmine": "2.8.7",
|
"@types/jasmine": "2.8.7",
|
||||||
@@ -54,7 +58,7 @@
|
|||||||
"@types/node": "8.9.4",
|
"@types/node": "8.9.4",
|
||||||
"codelyzer": "4.2.1",
|
"codelyzer": "4.2.1",
|
||||||
"core-js": "2.5.6",
|
"core-js": "2.5.6",
|
||||||
"electron": "2.0.2",
|
"electron": "2.0.3",
|
||||||
"electron-builder": "20.14.7",
|
"electron-builder": "20.14.7",
|
||||||
"electron-reload": "1.2.2",
|
"electron-reload": "1.2.2",
|
||||||
"jasmine-core": "3.1.0",
|
"jasmine-core": "3.1.0",
|
||||||
@@ -68,7 +72,7 @@
|
|||||||
"npx": "10.2.0",
|
"npx": "10.2.0",
|
||||||
"protractor": "5.3.2",
|
"protractor": "5.3.2",
|
||||||
"rxjs": "6.1.0",
|
"rxjs": "6.1.0",
|
||||||
"ts-node": "6.0.3",
|
"ts-node": "6.0.6",
|
||||||
"tslint": "5.10.0",
|
"tslint": "5.10.0",
|
||||||
"typescript": "2.7.2",
|
"typescript": "2.7.2",
|
||||||
"wait-on": "2.1.0",
|
"wait-on": "2.1.0",
|
||||||
|
|||||||
16
postinstall-web.js
Normal file
16
postinstall-web.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// Allow angular using electron module (native node modules)
|
||||||
|
const fs = require('fs');
|
||||||
|
const f_angular = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';
|
||||||
|
|
||||||
|
fs.readFile(f_angular, 'utf8', function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
var result = data.replace(/target: "electron-renderer",/g, '');
|
||||||
|
var result = result.replace(/target: "web",/g, '');
|
||||||
|
var result = result.replace(/return \{/g, 'return {target: "web",');
|
||||||
|
|
||||||
|
fs.writeFile(f_angular, result, 'utf8', function (err) {
|
||||||
|
if (err) return console.log(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -7,6 +7,7 @@ fs.readFile(f_angular, 'utf8', function (err, data) {
|
|||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
var result = data.replace(/target: "electron-renderer",/g, '');
|
var result = data.replace(/target: "electron-renderer",/g, '');
|
||||||
|
var result = result.replace(/target: "web",/g, '');
|
||||||
var result = result.replace(/return \{/g, 'return {target: "electron-renderer",');
|
var result = result.replace(/return \{/g, 'return {target: "electron-renderer",');
|
||||||
|
|
||||||
fs.writeFile(f_angular, result, 'utf8', function (err) {
|
fs.writeFile(f_angular, result, 'utf8', function (err) {
|
||||||
|
|||||||
@@ -57,14 +57,14 @@ import 'core-js/es7/reflect';
|
|||||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||||
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||||
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||||
*/
|
*/
|
||||||
// (window as any).__Zone_enable_cross_context_check = true;
|
// (window as any).__Zone_enable_cross_context_check = true;
|
||||||
|
|
||||||
/***************************************************************************************************
|
/***************************************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user