XF 2.0 How to automatically copy addon JavaScript files to js folder on save?

Hi!

I have some JavaScript files in my addon, which I have placed in _files/js/link/to/jsfile folder.
But I need to reference the file, of course, through a template, wherefore I have copied it to js/link/to/jsfile folder under the Xenforo main directory.
I would like to have it automated so that I do not need to copy the file every time I save the file in _files folder.
How can I do it best in XenForo development?

Thanks,
Tommi
 
Code:
<xf:js dev="path/to/file.js" addon="Your/AddOnId" prod="path/to/file.min.js" />

In the above example, your JS file will be loaded from your add-on root _files/js/path/to/file.js when dev mode is enabled and fullJs is enabled. When those modes are switched off (I.e when a user installs the add on) then the JS will be loaded from the XF root js/path/to/file.min.js. The build process takes care of copying the files from _files to the relevant location and optionally you can use build.json to minify any JS files.
 
Back
Top Bottom