11import * as esbuild from 'esbuild' ;
22import path from 'path' ;
3+ import fs from 'fs' ;
34import { fileURLToPath } from 'url' ;
45
56const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
67
8+ const workspaceResolve = {
9+ name : 'workspace-resolve' ,
10+ setup ( build ) {
11+ build . onResolve ( { filter : / ^ @ c l u x - c l i \/ / } , ( args ) => {
12+ if ( args . path === '@clux-cli/core' ) {
13+ return { path : path . resolve ( __dirname , '../core/dist/index.js' ) } ;
14+ }
15+ if (
16+ args . path === '@clux-cli/web' ||
17+ args . path === '@clux-cli/web/dist/server'
18+ ) {
19+ return { path : path . resolve ( __dirname , '../web/dist/server.js' ) } ;
20+ }
21+ } ) ;
22+ } ,
23+ } ;
24+
725await esbuild . build ( {
826 entryPoints : [ path . join ( __dirname , 'dist/index.js' ) ] ,
927 bundle : true ,
@@ -12,9 +30,10 @@ await esbuild.build({
1230 outfile : path . join ( __dirname , 'dist/index.js' ) ,
1331 allowOverwrite : true ,
1432 external : [ 'better-sqlite3' ] ,
15- alias : {
16- '@clux-cli/core' : path . join ( __dirname , '..' , 'core' , 'dist' , 'index.js' ) ,
17- '@clux-cli/web/dist/server' : path . join ( __dirname , '..' , 'web' , 'dist' , 'server.js' ) ,
18- '@clux-cli/web' : path . join ( __dirname , '..' , 'web' , 'dist' , 'server.js' ) ,
19- } ,
33+ plugins : [ workspaceResolve ] ,
2034} ) ;
35+
36+ // Copy web public assets into CLI dist so they're available at runtime
37+ const srcPublic = path . resolve ( __dirname , '../web/dist/public' ) ;
38+ const destPublic = path . resolve ( __dirname , 'dist/public' ) ;
39+ fs . cpSync ( srcPublic , destPublic , { recursive : true } ) ;
0 commit comments