Skip to content

Commit c728d9a

Browse files
committed
fix and ng run with different builders and environments
1 parent 93f374c commit c728d9a

31 files changed

+521
-506
lines changed

.eslintrc.json ._eslintrc.json

File renamed without changes.

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ tsconfig.serve.tsbuildinfo
33

44
# compiled output
55
/dist
6+
/dist-angular
7+
/dist-electron
68
/tmp
79
/out-tsc
810
/app-builds
@@ -55,3 +57,6 @@ cypress.env.json
5557

5658
cypress/screenshots/*
5759
cypress/videos/*
60+
src/environments/environment.dev.ts
61+
src/environments/environment.production.ts
62+
src/environments/environment.web.ts

README.md

+23-12
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,49 @@ THUMDER
77

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

10-
1110
# Introduction | Angular - Electron
1211

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

16-
1715
## Currently, runs with:
1816

1917
- Angular v10.2.5
2018
- Electron v8.4.1
2119
- Electron Builder v22.8.1
2220

23-
2421
## Included Commands
2522

26-
| Command | Description |
27-
| ------------------------ | ------------------------------------------------------------------------------------ |
28-
| `npm run ng:serve` | Execute the app in the browser |
29-
| `npm run build` | Build the app. Your built files are in the /dist folder. |
30-
| `npm run build:prod` | Build the app with Angular aot. Your built files are in the /dist folder. |
31-
| `npm run electron:local` | Builds your application and start electron |
32-
| `npm run electron:build` | Builds your application and creates an app consumable based on your operating system |
33-
23+
| Command | Description |
24+
|--------------------------------|--------------------------------------------------------------------------------------|
25+
| `npm run ng:serve-angular:dev` | Execute the app in the browser |
26+
| `npm run electron:local` | Builds your application and start electron |
27+
| `npm run electron:build` | Builds your application and creates an app consumable based on your operating system |
28+
29+
| Command | Description |
30+
|---------------------------------------|-------------|
31+
| `npm run ng:build:dev` | |
32+
| `npm run ng:build:web` | |
33+
| `npm run ng:build:production` | |
34+
| `npm run ng:build-angular:dev` | |
35+
| `npm run ng:build-angular:web` | |
36+
| `npm run ng:build-angular:production` | |
37+
| `npm run ng:serve:dev` | |
38+
| `npm run ng:serve:web` | |
39+
| `npm run ng:serve:production` | |
40+
| `npm run ng:serve-angular:dev` | |
41+
| `npm run ng:serve-angular:web` | |
42+
| `npm run ng:serve-angular:production` | |
3443

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

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

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

41-
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 ?
50+
YES! You can do it! Just by importing your library in npm dependencies section (not **devDependencies**)
51+
with `npm install --save`. It will be loaded by electron during build phase and added to your final package. Then use
52+
your library by importing it in `main.ts` file. Quite simple, isn't it ?
4253

4354
## E2E Testing
4455

angular.json

+211-5
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@
119119
"outputHashing": "all",
120120
"sourceMap": true,
121121
"namedChunks": false,
122-
"aot": true,
122+
"aot": false,
123123
"extractLicenses": true,
124124
"vendorChunk": false,
125125
"buildOptimizer": false,
126126
"fileReplacements": [
127127
{
128-
"replace": "src/environments/environment.ts",
128+
"replace": "src/environments/_environment.ts",
129129
"with": "src/environments/environment.dev.ts"
130130
}
131131
],
@@ -157,7 +157,7 @@
157157
"buildOptimizer": false,
158158
"fileReplacements": [
159159
{
160-
"replace": "src/environments/environment.ts",
160+
"replace": "src/environments/_environment.ts",
161161
"with": "src/environments/environment.web.ts"
162162
}
163163
],
@@ -189,8 +189,197 @@
189189
"buildOptimizer": false,
190190
"fileReplacements": [
191191
{
192-
"replace": "src/environments/environment.ts",
193-
"with": "src/environments/environment.prod.ts"
192+
"replace": "src/environments/_environment.ts",
193+
"with": "src/environments/environment.production.ts"
194+
}
195+
],
196+
"budgets": [
197+
{
198+
"type": "initial",
199+
"maximumWarning": "80mb",
200+
"maximumError": "100mb"
201+
}
202+
]
203+
}
204+
}
205+
},
206+
"build-angular": {
207+
"builder": "@angular-devkit/build-angular:browser",
208+
"options": {
209+
"outputPath": "dist-angular",
210+
"index": "src/index.html",
211+
"main": "src/main.ts",
212+
"tsConfig": "src/tsconfig.app.json",
213+
"polyfills": "src/polyfills.ts",
214+
"allowedCommonJsDependencies": [
215+
"admin-lte/plugins/chart.js/Chart.js",
216+
"chart.js",
217+
"pixi.js-keyboard",
218+
"pixi.js-mouse",
219+
"mini-signals",
220+
"@firebase/app-check",
221+
"socket.io-client",
222+
"datastructures-js",
223+
"thumder-ontology",
224+
"debug"
225+
],
226+
"assets": [
227+
"src/assets",
228+
{
229+
"glob": "LICENSE.md",
230+
"input": "./",
231+
"output": "./assets/md/"
232+
},
233+
{
234+
"glob": "COOKIES.md",
235+
"input": "./",
236+
"output": "./assets/md/"
237+
},
238+
{
239+
"glob": "CHANGELOG.md",
240+
"input": "./",
241+
"output": "./assets/md/"
242+
},
243+
{
244+
"glob": "README.md",
245+
"input": "./",
246+
"output": "./assets/md/"
247+
},
248+
{
249+
"glob": "ABOUT.md",
250+
"input": "./",
251+
"output": "./assets/md/"
252+
},
253+
{
254+
"glob": "Datapath_Schematic.svg",
255+
"input": "./assets",
256+
"output": "./assets/"
257+
},
258+
{
259+
"glob": "DLX-TABLE-Instructions.md",
260+
"input": "./",
261+
"output": "./assets/md/"
262+
}
263+
],
264+
"styles": [
265+
"src/styles.scss",
266+
"src/monaco-editor.scss",
267+
"src/assets/flag-icons-master/css/flag-icon.css",
268+
"src/assets/styles/dx.generic.custom-scheme-thumder.css",
269+
"node_modules/xterm/css/xterm.css",
270+
"node_modules/devextreme/dist/css/dx.light.css",
271+
"node_modules/admin-lte/plugins/fontawesome-free/css/all.css",
272+
"node_modules/admin-lte/plugins/overlayScrollbars/css/OverlayScrollbars.css",
273+
"node_modules/admin-lte/dist/css/adminlte.css",
274+
"node_modules/ngx-toastr/toastr.css",
275+
"node_modules/prismjs/themes/prism-okaidia.css",
276+
"node_modules/prismjs/plugins/line-highlight/prism-line-highlight.css",
277+
"node_modules/cookieconsent/build/cookieconsent.min.css"
278+
],
279+
"scripts": [
280+
"node_modules/admin-lte/plugins/jquery/jquery.min.js",
281+
"node_modules/admin-lte/plugins/bootstrap/js/bootstrap.bundle.js",
282+
"node_modules/admin-lte/plugins/overlayScrollbars/js/jquery.overlayScrollbars.js",
283+
"node_modules/admin-lte/dist/js/adminlte.js",
284+
"node_modules/admin-lte/plugins/jquery-mousewheel/jquery.mousewheel.js",
285+
"node_modules/admin-lte/plugins/raphael/raphael.js",
286+
"node_modules/admin-lte/plugins/chart.js/Chart.js",
287+
"node_modules/prismjs/prism.js",
288+
"node_modules/prismjs/components/prism-typescript.min.js",
289+
"node_modules/prismjs/components/prism-javascript.min.js",
290+
"node_modules/prismjs/components/prism-css.min.js",
291+
"node_modules/prismjs/plugins/line-numbers/prism-line-numbers.js",
292+
"node_modules/emoji-toolkit/lib/js/joypixels.min.js",
293+
"node_modules/cookieconsent/build/cookieconsent.min.js"
294+
]
295+
},
296+
"configurations": {
297+
"dev": {
298+
"optimization": {
299+
"scripts": false,
300+
"styles": {
301+
"minify": false,
302+
"inlineCritical": false
303+
},
304+
"fonts": {
305+
"inline": false
306+
}
307+
},
308+
"outputHashing": "all",
309+
"sourceMap": true,
310+
"namedChunks": false,
311+
"aot": true,
312+
"extractLicenses": true,
313+
"vendorChunk": false,
314+
"buildOptimizer": false,
315+
"fileReplacements": [
316+
{
317+
"replace": "src/environments/_environment.ts",
318+
"with": "src/environments/environment.dev.ts"
319+
}
320+
],
321+
"budgets": [
322+
{
323+
"type": "initial",
324+
"maximumWarning": "80mb",
325+
"maximumError": "100mb"
326+
}
327+
]
328+
},
329+
"web": {
330+
"optimization": {
331+
"scripts": false,
332+
"styles": {
333+
"minify": false,
334+
"inlineCritical": false
335+
},
336+
"fonts": {
337+
"inline": false
338+
}
339+
},
340+
"outputHashing": "all",
341+
"sourceMap": true,
342+
"namedChunks": false,
343+
"aot": false,
344+
"extractLicenses": true,
345+
"vendorChunk": false,
346+
"buildOptimizer": false,
347+
"fileReplacements": [
348+
{
349+
"replace": "src/environments/_environment.ts",
350+
"with": "src/environments/environment.web.ts"
351+
}
352+
],
353+
"budgets": [
354+
{
355+
"type": "initial",
356+
"maximumWarning": "80mb",
357+
"maximumError": "100mb"
358+
}
359+
]
360+
},
361+
"production": {
362+
"optimization": {
363+
"scripts": true,
364+
"styles": {
365+
"minify": false,
366+
"inlineCritical": false
367+
},
368+
"fonts": {
369+
"inline": true
370+
}
371+
},
372+
"outputHashing": "all",
373+
"sourceMap": false,
374+
"namedChunks": false,
375+
"aot": true,
376+
"extractLicenses": true,
377+
"vendorChunk": false,
378+
"buildOptimizer": false,
379+
"fileReplacements": [
380+
{
381+
"replace": "src/environments/_environment.ts",
382+
"with": "src/environments/environment.production.ts"
194383
}
195384
],
196385
"budgets": [
@@ -220,6 +409,23 @@
220409
}
221410
}
222411
},
412+
"serve-angular": {
413+
"builder": "@angular-devkit/build-angular:dev-server",
414+
"options": {
415+
"browserTarget": "thumder-angular-electron:build-angular"
416+
},
417+
"configurations": {
418+
"dev": {
419+
"browserTarget": "thumder-angular-electron:build-angular:dev"
420+
},
421+
"web": {
422+
"browserTarget": "thumder-angular-electron:build-angular:web"
423+
},
424+
"production": {
425+
"browserTarget": "thumder-angular-electron:build-angular:production"
426+
}
427+
}
428+
},
223429
"extract-i18n": {
224430
"builder": "@angular-devkit/build-angular:extract-i18n",
225431
"options": {

angular.webpack.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = (config, options) => {
66
config.target = 'electron-renderer';
77
if (options.fileReplacements) {
88
for (let fileReplacement of options.fileReplacements) {
9-
if (fileReplacement.replace !== 'src/environments/environment.ts') {
9+
if (fileReplacement.replace !== 'src/environments/_environment.ts') {
1010
continue;
1111
}
1212
let fileReplacementParts = fileReplacement['with'].split('.');

package.json

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thumder",
3-
"version": "1.2.9",
3+
"version": "1.3.0",
44
"description": "TFG - THUMDER (THe UltiMate Dlx EmulatoR): emulador multiplataforma DLX con fines didácticos",
55
"homepage": "https://github.com/nonodev96/THUMDER",
66
"author": {
@@ -29,16 +29,26 @@
2929
"scripts": {
3030
"ws:server": "node ../THUMDER-server/dist/main.js",
3131
"postinstall": "electron-builder install-app-deps",
32+
"ng:build:dev": "ng run thumder-angular-electron:build:dev",
33+
"ng:build:web": "ng run thumder-angular-electron:build:web",
34+
"ng:build:production": "ng run thumder-angular-electron:build:production",
35+
"ng:build-angular:dev": "ng run thumder-angular-electron:build-angular:dev",
36+
"ng:build-angular:web": "ng run thumder-angular-electron:build-angular:web",
37+
"ng:build-angular:production": "ng run thumder-angular-electron:build-angular:production",
38+
"ng:serve:dev": "ng run thumder-angular-electron:serve:dev -o",
39+
"ng:serve:web": "ng run thumder-angular-electron:serve:web -o",
40+
"ng:serve:production": "ng run thumder-angular-electron:serve:production -o",
41+
"ng:serve-angular:dev": "ng run thumder-angular-electron:serve-angular:dev -o",
42+
"ng:serve-angular:web": "ng run thumder-angular-electron:serve-angular:web -o",
43+
"ng:serve-angular:production": "ng run thumder-angular-electron:serve-angular:production -o",
3244
"ng": "ng",
33-
"start": "npm-run-all -p electron:serve ng:serve",
45+
"start": "npm-run-all -p electron:serve ng:serve:dev",
3446
"build": "npm run electron:serve-tsc && ng build --base-href ./",
35-
"build:dev": "npm run build -- -c dev",
3647
"build:prod": "npm run build -- -c production",
37-
"ng:serve": "ng serve -c web -o",
38-
"electron:serve-tsc": "tsc -p tsconfig.serve.json",
39-
"electron:serve": "wait-on tcp:4200 && npm run electron:serve-tsc && npx electron . --serve",
4048
"electron:local": "npm run build:prod && npx electron .",
4149
"electron:build": "npm run build:prod && electron-builder build",
50+
"electron:serve-tsc": "tsc -p tsconfig.serve.json",
51+
"electron:serve": "wait-on tcp:4200 && npm run electron:serve-tsc && npx electron . --serve",
4252
"electron-builder build": "electron-builder build",
4353
"test": "ng test --watch=false",
4454
"test:watch": "ng test",
@@ -81,6 +91,7 @@
8191
"@types/jquery": "3.5.6",
8292
"@types/mocha": "8.0.3",
8393
"@types/node": "14.14.35",
94+
"eslint": "7.10.0",
8495
"@typescript-eslint/eslint-plugin": "4.2.0",
8596
"@typescript-eslint/eslint-plugin-tslint": "4.2.0",
8697
"@typescript-eslint/parser": "4.2.0",
@@ -92,7 +103,6 @@
92103
"electron": "12.2.2",
93104
"electron-builder": "22.10.5",
94105
"electron-reload": "1.5.0",
95-
"eslint": "7.10.0",
96106
"eslint-plugin-cypress": "2.12.1",
97107
"jasmine-core": "~3.6.0",
98108
"jasmine-spec-reporter": "~5.0.0",

0 commit comments

Comments
 (0)