Skip to content

Instantly share code, notes, and snippets.

@petervmeijgaard
Created July 30, 2016 09:59
Show Gist options
  • Save petervmeijgaard/9e7334bcfc2c2d1d342681c5c0aa9404 to your computer and use it in GitHub Desktop.
Save petervmeijgaard/9e7334bcfc2c2d1d342681c5c0aa9404 to your computer and use it in GitHub Desktop.
Webpack Vue File Loader
export default {
file(file, async = false) {
console.log(file);
if (async) {
return (resolve) => {
require([`${file}`], resolve);
};
}
return require(`${file}`);
},
page(main, page, async = false) {
const path = `./../pages/${main}/${page}/${page}.vue`;
return this.file(path, async);
},
layout(layout, async = false) {
const path = `./../layouts/${layout}/${layout}.vue`;
return this.file(path, async);
},
component(component, async = false) {
const path = `./../components/${component}/${component}.vue`;
return this.file(path, async);
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment