mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	chore(dx/desktop): get prod build
This commit is contained in:
		| @@ -33,6 +33,7 @@ | |||||||
|   }, |   }, | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "dev": "cross-env NODE_OPTIONS=\"--import tsx\" NODE_ENV=development TRILIUM_ENV=dev TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=../server/src electron src/electron-main.ts", |     "dev": "cross-env NODE_OPTIONS=\"--import tsx\" NODE_ENV=development TRILIUM_ENV=dev TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=../server/src electron src/electron-main.ts", | ||||||
|  |     "build": "tsx scripts/build.ts", | ||||||
|     "start-prod": "nx build desktop && cross-env TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=dist TRILIUM_PORT=37841 electron dist/main.js" |     "start-prod": "nx build desktop && cross-env TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=dist TRILIUM_PORT=37841 electron dist/main.js" | ||||||
|   }, |   }, | ||||||
|   "license": "AGPL-3.0-only", |   "license": "AGPL-3.0-only", | ||||||
| @@ -63,63 +64,20 @@ | |||||||
|         "options": { |         "options": { | ||||||
|           "main": "apps/desktop/src/electron-main.ts", |           "main": "apps/desktop/src/electron-main.ts", | ||||||
|           "outputPath": "apps/desktop/dist", |           "outputPath": "apps/desktop/dist", | ||||||
|           "outputFileName": "main.js", |  | ||||||
|           "tsConfig": "apps/desktop/tsconfig.app.json", |           "tsConfig": "apps/desktop/tsconfig.app.json", | ||||||
|           "platform": "node", |  | ||||||
|           "external": [ |           "external": [ | ||||||
|             "electron", |             "electron", | ||||||
|             "@electron/remote", |             "@electron/remote", | ||||||
|             "better-sqlite3", |             "better-sqlite3", | ||||||
|             "./xhr-sync-worker.js" |             "./xhr-sync-worker.js" | ||||||
|           ], |           ], | ||||||
|           "format": [ |  | ||||||
|             "cjs" |  | ||||||
|           ], |  | ||||||
|           "thirdParty": true, |           "thirdParty": true, | ||||||
|           "declaration": false, |  | ||||||
|           "esbuildOptions": { |           "esbuildOptions": { | ||||||
|             "splitting": false, |             "splitting": false, | ||||||
|             "loader": { |             "loader": { | ||||||
|               ".css": "text" |               ".css": "text" | ||||||
|             } |             } | ||||||
|           }, |           }, | ||||||
|           "assets": [ |  | ||||||
|             { |  | ||||||
|               "glob": "**/*", |  | ||||||
|               "input": "apps/server/dist/node_modules", |  | ||||||
|               "output": "node_modules" |  | ||||||
|             }, |  | ||||||
|             { |  | ||||||
|               "glob": "**/*", |  | ||||||
|               "input": "apps/desktop/node_modules/@electron/remote", |  | ||||||
|               "output": "node_modules/@electron/remote" |  | ||||||
|             }, |  | ||||||
|             { |  | ||||||
|               "glob": "**/*", |  | ||||||
|               "input": "apps/server/dist/assets", |  | ||||||
|               "output": "assets" |  | ||||||
|             }, |  | ||||||
|             { |  | ||||||
|               "glob": "**/*", |  | ||||||
|               "input": "packages/share-theme/src/templates", |  | ||||||
|               "output": "share-theme/templates" |  | ||||||
|             }, |  | ||||||
|             { |  | ||||||
|               "glob": "**/*", |  | ||||||
|               "input": "apps/desktop/src/assets", |  | ||||||
|               "output": "assets" |  | ||||||
|             }, |  | ||||||
|             { |  | ||||||
|               "glob": "**/*", |  | ||||||
|               "input": "apps/server/dist/public", |  | ||||||
|               "output": "public" |  | ||||||
|             }, |  | ||||||
|             { |  | ||||||
|               "glob": "xhr-sync-worker.js", |  | ||||||
|               "input": "apps/server/node_modules/jsdom/lib/jsdom/living/xhr", |  | ||||||
|               "output": "" |  | ||||||
|             } |  | ||||||
|           ], |  | ||||||
|           "declarationRootDir": "apps/desktop/src" |           "declarationRootDir": "apps/desktop/src" | ||||||
|         } |         } | ||||||
|       }, |       }, | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								apps/desktop/scripts/build.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								apps/desktop/scripts/build.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | import BuildHelper from "../../../scripts/build-utils"; | ||||||
|  |  | ||||||
|  | const build = new BuildHelper("apps/desktop"); | ||||||
|  |  | ||||||
|  | async function main() { | ||||||
|  |     await build.buildBackend([ "src/main.ts"]); | ||||||
|  |  | ||||||
|  |     // Copy assets. | ||||||
|  |     build.copy("src/assets", "assets/"); | ||||||
|  |     build.copy("/apps/server/src/assets", "assets/"); | ||||||
|  |     build.copy("/packages/share-theme/src/templates", "share-theme/templates/"); | ||||||
|  |  | ||||||
|  |     // Copy node modules dependencies | ||||||
|  |     build.copyNodeModules([ "better-sqlite3", "bindings", "file-uri-to-path", "@electron/remote" ]); | ||||||
|  |     build.copy("/apps/server/node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js", "xhr-sync-worker.js"); | ||||||
|  |  | ||||||
|  |     // Integrate the client. | ||||||
|  |     build.triggerBuildAndCopyTo("apps/client", "public/"); | ||||||
|  |     build.deleteFromOutput("public/webpack-stats.json"); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | main(); | ||||||
| @@ -3,11 +3,11 @@ import BuildHelper from "../../../scripts/build-utils"; | |||||||
| const build = new BuildHelper("apps/server"); | const build = new BuildHelper("apps/server"); | ||||||
|  |  | ||||||
| async function main() { | async function main() { | ||||||
|     build.buildBackend([ "src/main.ts", "src/docker_healthcheck.ts" ]) |     await build.buildBackend([ "src/main.ts", "src/docker_healthcheck.ts" ]) | ||||||
|  |  | ||||||
|     // Copy assets |     // Copy assets | ||||||
|     build.copy("src/assets", "assets/"); |     build.copy("src/assets", "assets/"); | ||||||
|     build.copy("../../packages/share-theme/src/templates", "share-theme/templates/"); |     build.copy("/packages/share-theme/src/templates", "share-theme/templates/"); | ||||||
|  |  | ||||||
|     // Copy node modules dependencies |     // Copy node modules dependencies | ||||||
|     build.copyNodeModules([ "better-sqlite3", "bindings", "file-uri-to-path" ]); |     build.copyNodeModules([ "better-sqlite3", "bindings", "file-uri-to-path" ]); | ||||||
|   | |||||||
| @@ -19,10 +19,17 @@ export default class BuildHelper { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     copy(projectDirPath: string, outDirPath: string) { |     copy(projectDirPath: string, outDirPath: string) { | ||||||
|  |         let sourcePath: string; | ||||||
|  |         if (projectDirPath.startsWith("/")) { | ||||||
|  |             sourcePath = join(this.rootDir, projectDirPath.substring(1)); | ||||||
|  |         } else { | ||||||
|  |             sourcePath = join(this.projectDir, projectDirPath); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (outDirPath.endsWith("/")) { |         if (outDirPath.endsWith("/")) { | ||||||
|             mkdirpSync(join(outDirPath)); |             mkdirpSync(join(outDirPath)); | ||||||
|         } |         } | ||||||
|         copySync(join(this.projectDir, projectDirPath), join(this.outDir, outDirPath), { dereference: true }); |         copySync(sourcePath, join(this.outDir, outDirPath), { dereference: true }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     deleteFromOutput(path: string) { |     deleteFromOutput(path: string) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user