@@ -11,6 +11,8 @@ if you want to view the source, please visit the github repository of this plugi
1111` ;
1212
1313const prod = process . argv [ 2 ] === "production" ;
14+ const devVaultPath =
15+ "/home/lonoxx/Nextcloud/Obsidian/.obsidian/plugins/github-issues/" ;
1416
1517// Function to copy files to dist folder
1618function copyToDist ( files ) {
@@ -31,6 +33,33 @@ function copyToDist(files) {
3133 } ) ;
3234}
3335
36+ // Function to copy files from dist to dev vault
37+ function copyToDevVault ( ) {
38+ if ( ! fs . existsSync ( devVaultPath ) ) {
39+ fs . mkdirSync ( devVaultPath , { recursive : true } ) ;
40+ }
41+
42+ const distFiles = [
43+ "dist/main.js" ,
44+ "manifest.json" ,
45+ "styles.css" ,
46+ "versions.json" ,
47+ ] ;
48+
49+ distFiles . forEach ( ( file ) => {
50+ if ( fs . existsSync ( file ) ) {
51+ const fileName = path . basename ( file ) ;
52+ const destPath = path . join ( devVaultPath , fileName ) ;
53+ fs . copyFileSync ( file , destPath ) ;
54+ console . log ( `Copied ${ file } to ${ destPath } ` ) ;
55+ } else {
56+ console . warn (
57+ `Warning: ${ file } not found, skipping copy to dev vault` ,
58+ ) ;
59+ }
60+ } ) ;
61+ }
62+
3463const context = await esbuild . context ( {
3564 banner : {
3665 js : banner ,
@@ -60,11 +89,36 @@ const context = await esbuild.context({
6089 treeShaking : true ,
6190 outfile : "dist/main.js" ,
6291 minify : prod ,
92+ plugins : prod
93+ ? [ ]
94+ : [
95+ {
96+ name : "copy-to-dev-vault" ,
97+ setup ( build ) {
98+ build . onEnd ( ( result ) => {
99+ if ( result . errors . length === 0 ) {
100+ console . log ( "Copying to dev vault..." ) ;
101+ const mainJsPath = path . join (
102+ devVaultPath ,
103+ "main.js" ,
104+ ) ;
105+ if ( fs . existsSync ( "dist/main.js" ) ) {
106+ fs . copyFileSync ( "dist/main.js" , mainJsPath ) ;
107+ console . log (
108+ `Copied dist/main.js → ${ mainJsPath } ` ,
109+ ) ;
110+ }
111+ }
112+ } ) ;
113+ } ,
114+ } ,
115+ ] ,
63116} ) ;
64117
65118if ( prod ) {
66119 await context . rebuild ( ) ;
67120 copyToDist ( [ "versions.json" , "manifest.json" , "styles.css" ] ) ;
121+ copyToDevVault ( ) ;
68122 process . exit ( 0 ) ;
69123} else {
70124 await context . watch ( ) ;
0 commit comments