Skip to content

Instantly share code, notes, and snippets.

@ntnyq
Last active September 6, 2019 09:59
Show Gist options
  • Save ntnyq/9ccbbcdf680d9ef637fae8743595bf61 to your computer and use it in GitHub Desktop.
Save ntnyq/9ccbbcdf680d9ef637fae8743595bf61 to your computer and use it in GitHub Desktop.
[Webpack tricks] #Webpack
const files = require.context('.', true, /models\/[^/]+\.js$/)
files.keys().forEach(key => {
module.exports[key.replace(/\.\/models\/|\.js/g, '')] = files(key).default
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment