XF 2.1 External js files in an add-on

TiKu

Member
Hi,

My add-on references a js file which I have placed in _files/js/vendor. In the template modification I reference it this way:
Code:
<xf:js dev="vendor/mylib.js" prod="vendor/mylib.min.js" addon="My/AddOn" />
My build.json looks like this:
Code:
{
    "additional_files": [
        "js/vendor/"
    ],
    "minify": [
        "js/vendor/mylib.js"
    ]
}
Is this the correct way to do it? I'm asking because in the release the js file is placed in <xenForo Root>/js/vendor and not somewhere in the add-on's directory. Both directories make sense to me. I just want to be sure that I'm doing it the "official way".
 
Unless you're using a different set of files for development and production (typically in the case of roll-ups), you can use:
HTML:
<xf:js addon="My/AddOn" src="vendor/mylib.js" min="1" />

Also, I don't think directory entries in additional_files need trailing slashes, but I suppose it shouldn't hurt anything. It is correct that the files end up in the XF js/ directory. All additional files in an add-on _files/ directory are bundled relative to the XF root.
 
Back
Top Bottom