@@ -580,6 +580,76 @@ if (fs.existsSync(bpmnDir)) {
580
580
console . warn ( 'BPMN directory not found!' ) ;
581
581
}
582
582
583
+ // Copy BPMN.io directly from node_modules to ensure version consistency
584
+ console . log ( 'Copying BPMN.io from node_modules...' ) ;
585
+ const bpmnJsDir = path . join ( distDir , 'js' , 'bpmn-js' ) ;
586
+ if ( ! fs . existsSync ( bpmnJsDir ) ) {
587
+ fs . mkdirSync ( bpmnJsDir , { recursive : true } ) ;
588
+ }
589
+
590
+ // Copy the specific bpmn-js distributable files from node_modules
591
+ const bpmnJsNodeModule = path . join ( 'node_modules' , 'bpmn-js' , 'dist' ) ;
592
+ if ( fs . existsSync ( bpmnJsNodeModule ) ) {
593
+ // Copy the minified version
594
+ fs . copyFileSync (
595
+ path . join ( bpmnJsNodeModule , 'bpmn-navigated-viewer.production.min.js' ) ,
596
+ path . join ( bpmnJsDir , 'bpmn-navigated-viewer.min.js' )
597
+ ) ;
598
+ console . log ( 'Copied bpmn-js library from node_modules' ) ;
599
+
600
+ // Also copy the development version for better debugging
601
+ fs . copyFileSync (
602
+ path . join ( bpmnJsNodeModule , 'bpmn-navigated-viewer.development.js' ) ,
603
+ path . join ( bpmnJsDir , 'bpmn-navigated-viewer.js' )
604
+ ) ;
605
+ console . log ( 'Copied bpmn-js development version for debugging' ) ;
606
+
607
+ // Copy the CSS file if it exists
608
+ const bpmnCssPath = path . join ( bpmnJsNodeModule , 'assets' , 'bpmn-js.css' ) ;
609
+ if ( fs . existsSync ( bpmnCssPath ) ) {
610
+ const cssDir = path . join ( distDir , 'css' ) ;
611
+ if ( ! fs . existsSync ( cssDir ) ) {
612
+ fs . mkdirSync ( cssDir , { recursive : true } ) ;
613
+ }
614
+ fs . copyFileSync ( bpmnCssPath , path . join ( cssDir , 'bpmn-js.css' ) ) ;
615
+ console . log ( 'Copied bpmn-js CSS' ) ;
616
+ }
617
+ } else {
618
+ console . warn ( 'bpmn-js not found in node_modules! Using bundled version instead.' ) ;
619
+ }
620
+
621
+ // Create directories for static assets
622
+ console . log ( 'Creating directories for static assets...' ) ;
623
+ const imagesDir = path . join ( distDir , 'images' ) ;
624
+
625
+ // Create directories if they don't exist
626
+ if ( ! fs . existsSync ( imagesDir ) ) fs . mkdirSync ( imagesDir , { recursive : true } ) ;
627
+
628
+ // Copy images to dist directory
629
+ console . log ( 'Copying images to dist directory...' ) ;
630
+ const sourceImagesDir = path . join ( __dirname , 'images' ) ;
631
+ if ( fs . existsSync ( sourceImagesDir ) ) {
632
+ const imageFiles = fs . readdirSync ( sourceImagesDir ) ;
633
+ console . log ( `Found ${ imageFiles . length } images to copy` ) ;
634
+
635
+ imageFiles . forEach ( file => {
636
+ const sourcePath = path . join ( sourceImagesDir , file ) ;
637
+ const destPath = path . join ( imagesDir , file ) ;
638
+
639
+ // Check if source is a file (not a directory)
640
+ if ( fs . statSync ( sourcePath ) . isFile ( ) ) {
641
+ fs . copyFileSync ( sourcePath , destPath ) ;
642
+ console . log ( `Copied ${ file } to ${ destPath } ` ) ;
643
+ } else {
644
+ console . log ( `Skipping directory ${ file } ` ) ;
645
+ }
646
+ } ) ;
647
+ } else {
648
+ console . warn ( 'Images directory not found in source!' ) ;
649
+ console . log ( 'Creating empty images directory in dist...' ) ;
650
+ fs . mkdirSync ( imagesDir , { recursive : true } ) ;
651
+ }
652
+
583
653
// Main build process
584
654
async function build ( ) {
585
655
try {
0 commit comments