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": { |         "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", |           "declarationRootDir": "apps/server/src", | ||||||
|           "thirdParty": true, |           "thirdParty": true, | ||||||
|           "declaration": false, |           "declaration": false, | ||||||
|           "esbuildOptions": { |  | ||||||
|             "splitting": false, |  | ||||||
|             "loader": { |  | ||||||
|               ".css": "text", |  | ||||||
|               ".ejs": "text" |  | ||||||
|             } |  | ||||||
|           }, |  | ||||||
|           "additionalEntryPoints": [ |           "additionalEntryPoints": [ | ||||||
|             "apps/server/src/docker_healthcheck.ts" |             "apps/server/src/docker_healthcheck.ts" | ||||||
|           ], |           ], | ||||||
|           "assets": [ |           "assets": [ | ||||||
|             { |  | ||||||
|               "glob": "**/*", |  | ||||||
|               "input": "apps/server/src/assets", |  | ||||||
|               "output": "assets" |  | ||||||
|             }, |  | ||||||
|             { |             { | ||||||
|               "glob": "**/*", |               "glob": "**/*", | ||||||
|               "input": "packages/share-theme/src/templates", |               "input": "packages/share-theme/src/templates", | ||||||
| @@ -328,26 +303,6 @@ | |||||||
|               "ignore": [ |               "ignore": [ | ||||||
|                 "webpack-stats.json" |                 "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": { |   "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" |   "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