@@ -17,9 +17,9 @@ type ReScriptProcess = {
1717async function launchReScript (
1818 watch : boolean ,
1919 silent : boolean ,
20+ buildArgs : string ,
2021) : Promise < ReScriptProcess > {
21- const cmd = watch ? 'rescript watch' : 'rescript build' ;
22-
22+ const cmd = ( watch ? 'rescript watch' : 'rescript build' ) + ' ' + buildArgs ;
2323 // https://github.com/rescript-lang/rescript/blob/9676953f5b5ce96ade6909af3f23a77cd69645e9/rewatch/src/watcher.rs#L246-L258
2424 const finishSignal = 'Finished initial compilation' ;
2525
@@ -71,6 +71,7 @@ interface Config {
7171 suffix ?: string ;
7272 } ;
7373 silent ?: boolean ;
74+ buildArgs ?: string ;
7475}
7576
7677export default function createReScriptPlugin ( config ?: Config ) : Plugin {
@@ -83,6 +84,7 @@ export default function createReScriptPlugin(config?: Config): Plugin {
8384 const suffix = config ?. loader ?. suffix ?? '.bs.js' ;
8485 const suffixRegex = new RegExp ( `${ suffix . replace ( '.' , '\\.' ) } $` ) ;
8586 const silent = config ?. silent ?? false ;
87+ const buildArgs = config ?. buildArgs ?? '' ;
8688
8789 return {
8890 name : '@jihchi/vite-plugin-rescript' ,
@@ -106,7 +108,7 @@ export default function createReScriptPlugin(config?: Config): Plugin {
106108 const watch = ! isLocked && ( command === 'serve' || Boolean ( build . watch ) ) ;
107109
108110 if ( needReScript ) {
109- childProcessReScript = await launchReScript ( watch , silent ) ;
111+ childProcessReScript = await launchReScript ( watch , silent , buildArgs ) ;
110112 }
111113 } ,
112114 config : ( userConfig ) => ( {
0 commit comments