mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	chore(monorepo/server): find workaround to copy node modules
This commit is contained in:
		
							parent
							
								
									81e6537007
								
							
						
					
					
						commit
						2325fbc72d
					
				| @ -28,6 +28,29 @@ function copyAssets(baseDir: string, destDir: string, files: string[]) { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Copies the dependencies from the node_modules directory to the build directory. | ||||
|  * We cannot copy the node_modules directory directly because we are in a monorepo and all the packages are gathered at root level. | ||||
|  *  | ||||
|  * @param packageJsonPath  | ||||
|  */ | ||||
| function copyNodeModules(packageJsonPath: string) { | ||||
|     const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); | ||||
|     const dependencies = packageJson.dependencies || {}; | ||||
| 
 | ||||
|     for (const dependency of Object.keys(dependencies)) { | ||||
|         if (dependency.startsWith("@triliumnext/")) { | ||||
|             // Skip copying @triliumnext dependencies since they are symlinked in the monorepo.
 | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         const src = path.join(rootDir, "node_modules", dependency); | ||||
|         const dest = path.join(DEST_DIR, "node_modules", dependency); | ||||
|         log(`${src} -> ${dest}`); | ||||
|         fs.copySync(src, dest); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| try { | ||||
|     const clientAssets = [ | ||||
|         "./libraries", | ||||
| @ -59,6 +82,7 @@ try { | ||||
|         "README.md"     | ||||
|     ]; | ||||
| 
 | ||||
|     copyNodeModules(path.join(serverDir, "package.json")); | ||||
|     copyAssets(clientDir, path.join(DEST_DIR, "src", "public"), clientAssets); | ||||
|     copyAssets(serverDir, path.join(DEST_DIR), serverAssets); | ||||
|     copyAssets(rootDir, path.join(DEST_DIR), rootAssets); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran