Skip to content

Instantly share code, notes, and snippets.

@mlynarczyk
Created April 14, 2018 23:58
Show Gist options
  • Save mlynarczyk/2ae02bd134fd613ae836c29e2a0a76df to your computer and use it in GitHub Desktop.
Save mlynarczyk/2ae02bd134fd613ae836c29e2a0a76df to your computer and use it in GitHub Desktop.
webpack import components directory
const viewsContext = require.context('./views', false, /\.vue$/);
let views = {};
viewsContext.keys().forEach((key) => {
const name = viewsContext(key).default.name;
views[name] = viewsContext(key).default;
});
@mlynarczyk
Copy link
Author

dont use in files you gonna test, you either gonna have to mock or polyfill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment