mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	chore(dx/server): start building & copying assets
This commit is contained in:
		| @@ -284,38 +284,13 @@ | ||||
|           } | ||||
|         }, | ||||
|         "options": { | ||||
|           "main": "apps/server/src/main.ts", | ||||
|           "outputPath": "apps/server/dist", | ||||
|           "tsConfig": "apps/server/tsconfig.app.json", | ||||
|           "platform": "node", | ||||
|           "external": [ | ||||
|             "electron", | ||||
|             "@electron/remote", | ||||
|             "better-sqlite3", | ||||
|             "./xhr-sync-worker.js" | ||||
|           ], | ||||
|           "format": [ | ||||
|             "cjs" | ||||
|           ], | ||||
|           "declarationRootDir": "apps/server/src", | ||||
|           "thirdParty": true, | ||||
|           "declaration": false, | ||||
|           "esbuildOptions": { | ||||
|             "splitting": false, | ||||
|             "loader": { | ||||
|               ".css": "text", | ||||
|               ".ejs": "text" | ||||
|             } | ||||
|           }, | ||||
|           "additionalEntryPoints": [ | ||||
|             "apps/server/src/docker_healthcheck.ts" | ||||
|           ], | ||||
|           "assets": [ | ||||
|             { | ||||
|               "glob": "**/*", | ||||
|               "input": "apps/server/src/assets", | ||||
|               "output": "assets" | ||||
|             }, | ||||
|             { | ||||
|               "glob": "**/*", | ||||
|               "input": "packages/share-theme/src/templates", | ||||
| @@ -328,26 +303,6 @@ | ||||
|               "ignore": [ | ||||
|                 "webpack-stats.json" | ||||
|               ] | ||||
|             }, | ||||
|             { | ||||
|               "glob": "**/*", | ||||
|               "input": "apps/server/node_modules/better-sqlite3", | ||||
|               "output": "node_modules/better-sqlite3" | ||||
|             }, | ||||
|             { | ||||
|               "glob": "**/*", | ||||
|               "input": "apps/server/node_modules/bindings", | ||||
|               "output": "node_modules/bindings" | ||||
|             }, | ||||
|             { | ||||
|               "glob": "**/*", | ||||
|               "input": "apps/server/node_modules/file-uri-to-path", | ||||
|               "output": "node_modules/file-uri-to-path" | ||||
|             }, | ||||
|             { | ||||
|               "glob": "xhr-sync-worker.js", | ||||
|               "input": "apps/server/node_modules/jsdom/lib/jsdom/living/xhr", | ||||
|               "output": "" | ||||
|             } | ||||
|           ] | ||||
|         } | ||||
| @@ -364,7 +319,8 @@ | ||||
|     } | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "dev": "cross-env TRILIUM_ENV=dev TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=src tsx watch --ignore '../client/node_modules/.vite-temp' ./src/main.ts" | ||||
|     "dev": "cross-env TRILIUM_ENV=dev TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=src tsx watch --ignore '../client/node_modules/.vite-temp' ./src/main.ts", | ||||
|     "build": "tsx scripts/build.ts" | ||||
|   }, | ||||
|   "main": "./src/main.ts" | ||||
| } | ||||
							
								
								
									
										53
									
								
								apps/server/scripts/build.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								apps/server/scripts/build.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| import * as esbuild from "esbuild"; | ||||
| import { join } from "path"; | ||||
| import * as fs from "fs-extra"; | ||||
|  | ||||
| const projectDir = __dirname + "/.."; | ||||
| const outDir = join(projectDir, "dist"); | ||||
|  | ||||
| async function build() { | ||||
|     esbuild.build({ | ||||
|         entryPoints: [ join(projectDir, "src/main.ts") ], | ||||
|         tsconfig: join(projectDir, "tsconfig.app.json"), | ||||
|         platform: "node", | ||||
|         bundle: true, | ||||
|         outdir: outDir, | ||||
|         format: "cjs", | ||||
|         external: [ | ||||
|             "electron", | ||||
|             "@electron/remote", | ||||
|             "better-sqlite3", | ||||
|             "./xhr-sync-worker.js", | ||||
|             "@preact/preset-vite", | ||||
|             "vite" | ||||
|         ], | ||||
|         splitting: false, | ||||
|         loader: { | ||||
|             ".css": "text", | ||||
|             ".ejs": "text" | ||||
|         } | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function copyAssets() { | ||||
|     // Copy server assets | ||||
|     fs.copySync(join(projectDir, "src/assets"), join(outDir, "assets")); | ||||
|  | ||||
|     // Copy node modules | ||||
|     fs.mkdir(join(outDir, "node_modules")); | ||||
|     for (const module of [ "better-sqlite3", "bindings", "file-uri-to-path" ]) { | ||||
|         fs.copySync(join(projectDir, "node_modules", module), join(outDir, "node_modules", module), { dereference: true }); | ||||
|     } | ||||
|  | ||||
|     // Copy sync worker. | ||||
|     fs.copySync(join(projectDir, "node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js"), join(outDir, "xhr-sync-worker.js")); | ||||
| } | ||||
|  | ||||
| async function main() { | ||||
|     fs.rmSync(outDir, { recursive: true }); | ||||
|     fs.mkdirSync(outDir); | ||||
|     await build(); | ||||
|     copyAssets(); | ||||
| } | ||||
|  | ||||
| main(); | ||||
		Reference in New Issue
	
	Block a user