Refactor assets function into a plugin.