Automatically copy contents of _files to styles/... or js/... for current development addon


Well-known member
It feels bad to me that in order to use the _files directory for add-on development, I will need to manually copy its contents to my styles/whatever or js/whatever during development. I feel like it should work just like template development does, which is to check the filesystem for template changes, import them into the database and use them without me thinking about it. On page load, it would scan the folder for files, see which is newer and override from the _files folder to the external destination. I am not sure how you even envision this workflow to be. Copying a file manually between the two seems like a great source of false debugging when you don't understand how something is not fixed, etc.
Upvote 0

Jeremy P

XenForo developer
Staff member
You can reference JS in your templates using a special syntax to have them served from your add-on directory during development:

<xf:js addon="Vendor/AddOn" src="vendor/addon/file.js" min="1" />

Unfortunately there's nothing similar for images and such at present, but I typically use symbolic links as a work-around.


Well-known member

Yeah, that could work, but the problem is I would want check those symlinks into git. And my ideal is to only commit my src/addons/MyAddon to git, not all of XenForo.

I am in the progress of making a .gitignore that ignores all of XenForo except my stuff. Here is a snippet. It's a huge kludge.
# Ignore everything in www

# Except _something_ in www/js

# Except my addon things

# Except _something_ www/src

# Except addons and stypes

# Ignore all add-ons except my things

# Ignore all designer styles except mine

It would be so ideal to just have the .git folder inside src/addons/MyAddon.

Jeremy P

XenForo developer
Staff member
It would be so ideal to just have the .git folder inside src/addons/MyAddon.
I'm not sure if there's something specific to your workflow that prevents this, but for what it's worth I do typically have one repository per add-on and simply clone the repository into the add-on's vendor folder. The symbolic link exists both in my development and production environments, but outside the purview of git.

It is possible to check symbolic links into a repository, whether that means having a separate repository for your XF root or having a monorepo for your XF installation and all of your add-ons, but understandably that can be a bit cumbersome to set up and work with.

Nevertheless I do think this is a valid suggestion, I was just sharing a work-around.