Skip to content

Commit

Permalink
fix and ng run with different builders and environments
Browse files Browse the repository at this point in the history
  • Loading branch information
nonodev96 committed Dec 28, 2021
1 parent 93f374c commit c728d9a
Show file tree
Hide file tree
Showing 31 changed files with 521 additions and 506 deletions.
File renamed without changes.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ tsconfig.serve.tsbuildinfo

# compiled output
/dist
/dist-angular
/dist-electron
/tmp
/out-tsc
/app-builds
Expand Down Expand Up @@ -55,3 +57,6 @@ cypress.env.json

cypress/screenshots/*
cypress/videos/*
src/environments/environment.dev.ts
src/environments/environment.production.ts
src/environments/environment.web.ts
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,49 @@ THUMDER

[![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE.md)


# Introduction | Angular - Electron

[![Angular Logo](https://www.vectorlogo.zone/logos/angular/angular-icon.svg)](https://angular.io/)
[![Electron Logo](https://www.vectorlogo.zone/logos/electronjs/electronjs-icon.svg)](https://electronjs.org/)


## Currently, runs with:

- Angular v10.2.5
- Electron v8.4.1
- Electron Builder v22.8.1


## Included Commands

| Command | Description |
| ------------------------ | ------------------------------------------------------------------------------------ |
| `npm run ng:serve` | Execute the app in the browser |
| `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 electron:local` | Builds your application and start electron |
| `npm run electron:build` | Builds your application and creates an app consumable based on your operating system |

| Command | Description |
|--------------------------------|--------------------------------------------------------------------------------------|
| `npm run ng:serve-angular:dev` | Execute the app in the browser |
| `npm run electron:local` | Builds your application and start electron |
| `npm run electron:build` | Builds your application and creates an app consumable based on your operating system |

| Command | Description |
|---------------------------------------|-------------|
| `npm run ng:build:dev` | |
| `npm run ng:build:web` | |
| `npm run ng:build:production` | |
| `npm run ng:build-angular:dev` | |
| `npm run ng:build-angular:web` | |
| `npm run ng:build-angular:production` | |
| `npm run ng:serve:dev` | |
| `npm run ng:serve:web` | |
| `npm run ng:serve:production` | |
| `npm run ng:serve-angular:dev` | |
| `npm run ng:serve-angular:web` | |
| `npm run ng:serve-angular:production` | |

You need to change de space of node with `NODE_OPTIONS` `--max_old_space_size=<size>`

**Your application is optimised. Only /dist folder and node dependencies are included in the executable.**

## You want to use a specific lib (like rxjs) in electron main thread ?

YES! You can do it! Just by importing your library in npm dependencies section (not **devDependencies**) with `npm install --save`. It will be loaded by electron during build phase and added to your final package. Then use your library by importing it in `main.ts` file. Quite simple, isn't it ?
YES! You can do it! Just by importing your library in npm dependencies section (not **devDependencies**)
with `npm install --save`. It will be loaded by electron during build phase and added to your final package. Then use
your library by importing it in `main.ts` file. Quite simple, isn't it ?

## E2E Testing

Expand Down
216 changes: 211 additions & 5 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@
"outputHashing": "all",
"sourceMap": true,
"namedChunks": false,
"aot": true,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"replace": "src/environments/_environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
Expand Down Expand Up @@ -157,7 +157,7 @@
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"replace": "src/environments/_environment.ts",
"with": "src/environments/environment.web.ts"
}
],
Expand Down Expand Up @@ -189,8 +189,197 @@
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
"replace": "src/environments/_environment.ts",
"with": "src/environments/environment.production.ts"
}
],
"budgets": [
{
"type": "initial",
"maximumWarning": "80mb",
"maximumError": "100mb"
}
]
}
}
},
"build-angular": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist-angular",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"allowedCommonJsDependencies": [
"admin-lte/plugins/chart.js/Chart.js",
"chart.js",
"pixi.js-keyboard",
"pixi.js-mouse",
"mini-signals",
"@firebase/app-check",
"socket.io-client",
"datastructures-js",
"thumder-ontology",
"debug"
],
"assets": [
"src/assets",
{
"glob": "LICENSE.md",
"input": "./",
"output": "./assets/md/"
},
{
"glob": "COOKIES.md",
"input": "./",
"output": "./assets/md/"
},
{
"glob": "CHANGELOG.md",
"input": "./",
"output": "./assets/md/"
},
{
"glob": "README.md",
"input": "./",
"output": "./assets/md/"
},
{
"glob": "ABOUT.md",
"input": "./",
"output": "./assets/md/"
},
{
"glob": "Datapath_Schematic.svg",
"input": "./assets",
"output": "./assets/"
},
{
"glob": "DLX-TABLE-Instructions.md",
"input": "./",
"output": "./assets/md/"
}
],
"styles": [
"src/styles.scss",
"src/monaco-editor.scss",
"src/assets/flag-icons-master/css/flag-icon.css",
"src/assets/styles/dx.generic.custom-scheme-thumder.css",
"node_modules/xterm/css/xterm.css",
"node_modules/devextreme/dist/css/dx.light.css",
"node_modules/admin-lte/plugins/fontawesome-free/css/all.css",
"node_modules/admin-lte/plugins/overlayScrollbars/css/OverlayScrollbars.css",
"node_modules/admin-lte/dist/css/adminlte.css",
"node_modules/ngx-toastr/toastr.css",
"node_modules/prismjs/themes/prism-okaidia.css",
"node_modules/prismjs/plugins/line-highlight/prism-line-highlight.css",
"node_modules/cookieconsent/build/cookieconsent.min.css"
],
"scripts": [
"node_modules/admin-lte/plugins/jquery/jquery.min.js",
"node_modules/admin-lte/plugins/bootstrap/js/bootstrap.bundle.js",
"node_modules/admin-lte/plugins/overlayScrollbars/js/jquery.overlayScrollbars.js",
"node_modules/admin-lte/dist/js/adminlte.js",
"node_modules/admin-lte/plugins/jquery-mousewheel/jquery.mousewheel.js",
"node_modules/admin-lte/plugins/raphael/raphael.js",
"node_modules/admin-lte/plugins/chart.js/Chart.js",
"node_modules/prismjs/prism.js",
"node_modules/prismjs/components/prism-typescript.min.js",
"node_modules/prismjs/components/prism-javascript.min.js",
"node_modules/prismjs/components/prism-css.min.js",
"node_modules/prismjs/plugins/line-numbers/prism-line-numbers.js",
"node_modules/emoji-toolkit/lib/js/joypixels.min.js",
"node_modules/cookieconsent/build/cookieconsent.min.js"
]
},
"configurations": {
"dev": {
"optimization": {
"scripts": false,
"styles": {
"minify": false,
"inlineCritical": false
},
"fonts": {
"inline": false
}
},
"outputHashing": "all",
"sourceMap": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/_environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"budgets": [
{
"type": "initial",
"maximumWarning": "80mb",
"maximumError": "100mb"
}
]
},
"web": {
"optimization": {
"scripts": false,
"styles": {
"minify": false,
"inlineCritical": false
},
"fonts": {
"inline": false
}
},
"outputHashing": "all",
"sourceMap": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/_environment.ts",
"with": "src/environments/environment.web.ts"
}
],
"budgets": [
{
"type": "initial",
"maximumWarning": "80mb",
"maximumError": "100mb"
}
]
},
"production": {
"optimization": {
"scripts": true,
"styles": {
"minify": false,
"inlineCritical": false
},
"fonts": {
"inline": true
}
},
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/_environment.ts",
"with": "src/environments/environment.production.ts"
}
],
"budgets": [
Expand Down Expand Up @@ -220,6 +409,23 @@
}
}
},
"serve-angular": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "thumder-angular-electron:build-angular"
},
"configurations": {
"dev": {
"browserTarget": "thumder-angular-electron:build-angular:dev"
},
"web": {
"browserTarget": "thumder-angular-electron:build-angular:web"
},
"production": {
"browserTarget": "thumder-angular-electron:build-angular:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
Expand Down
2 changes: 1 addition & 1 deletion angular.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = (config, options) => {
config.target = 'electron-renderer';
if (options.fileReplacements) {
for (let fileReplacement of options.fileReplacements) {
if (fileReplacement.replace !== 'src/environments/environment.ts') {
if (fileReplacement.replace !== 'src/environments/_environment.ts') {
continue;
}
let fileReplacementParts = fileReplacement['with'].split('.');
Expand Down
24 changes: 17 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thumder",
"version": "1.2.9",
"version": "1.3.0",
"description": "TFG - THUMDER (THe UltiMate Dlx EmulatoR): emulador multiplataforma DLX con fines didácticos",
"homepage": "https://github.com/nonodev96/THUMDER",
"author": {
Expand Down Expand Up @@ -29,16 +29,26 @@
"scripts": {
"ws:server": "node ../THUMDER-server/dist/main.js",
"postinstall": "electron-builder install-app-deps",
"ng:build:dev": "ng run thumder-angular-electron:build:dev",
"ng:build:web": "ng run thumder-angular-electron:build:web",
"ng:build:production": "ng run thumder-angular-electron:build:production",
"ng:build-angular:dev": "ng run thumder-angular-electron:build-angular:dev",
"ng:build-angular:web": "ng run thumder-angular-electron:build-angular:web",
"ng:build-angular:production": "ng run thumder-angular-electron:build-angular:production",
"ng:serve:dev": "ng run thumder-angular-electron:serve:dev -o",
"ng:serve:web": "ng run thumder-angular-electron:serve:web -o",
"ng:serve:production": "ng run thumder-angular-electron:serve:production -o",
"ng:serve-angular:dev": "ng run thumder-angular-electron:serve-angular:dev -o",
"ng:serve-angular:web": "ng run thumder-angular-electron:serve-angular:web -o",
"ng:serve-angular:production": "ng run thumder-angular-electron:serve-angular:production -o",
"ng": "ng",
"start": "npm-run-all -p electron:serve ng:serve",
"start": "npm-run-all -p electron:serve ng:serve:dev",
"build": "npm run electron:serve-tsc && ng build --base-href ./",
"build:dev": "npm run build -- -c dev",
"build:prod": "npm run build -- -c production",
"ng:serve": "ng serve -c web -o",
"electron:serve-tsc": "tsc -p tsconfig.serve.json",
"electron:serve": "wait-on tcp:4200 && npm run electron:serve-tsc && npx electron . --serve",
"electron:local": "npm run build:prod && npx electron .",
"electron:build": "npm run build:prod && electron-builder build",
"electron:serve-tsc": "tsc -p tsconfig.serve.json",
"electron:serve": "wait-on tcp:4200 && npm run electron:serve-tsc && npx electron . --serve",
"electron-builder build": "electron-builder build",
"test": "ng test --watch=false",
"test:watch": "ng test",
Expand Down Expand Up @@ -81,6 +91,7 @@
"@types/jquery": "3.5.6",
"@types/mocha": "8.0.3",
"@types/node": "14.14.35",
"eslint": "7.10.0",
"@typescript-eslint/eslint-plugin": "4.2.0",
"@typescript-eslint/eslint-plugin-tslint": "4.2.0",
"@typescript-eslint/parser": "4.2.0",
Expand All @@ -92,7 +103,6 @@
"electron": "12.2.2",
"electron-builder": "22.10.5",
"electron-reload": "1.5.0",
"eslint": "7.10.0",
"eslint-plugin-cypress": "2.12.1",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
Expand Down
Loading

0 comments on commit c728d9a

Please sign in to comment.