[Vuejs]-Vue filters not resolved when file outside of project root

0👍

The reason for this is that Vue.filter() is being called on a different instance of Vue when it is being included based on a different package.json, even if it specifies the same version. There may be a way to tell webpack a way to compile these things differently, but a better approach is to convert the filters to a plugin, with an install script that you pass Vue to, so it’s whichever Vue you’re already using:

  const vueFilters = {
    install(Vue) {
      Vue.filter('useless', value => {
        return value;
      });
    }
  };

  export default vueFilters;  

Leave a comment