Skip to content

Instantly share code, notes, and snippets.

@joshhunt
Created May 3, 2015 04:58
Show Gist options
  • Select an option

  • Save joshhunt/7433a7496aff505ccbbb to your computer and use it in GitHub Desktop.

Select an option

Save joshhunt/7433a7496aff505ccbbb to your computer and use it in GitHub Desktop.
Create loaders from a shim config
makeLoaderFromShim = (toShim, fileName) ->
_makeGlobalLoader = (toShim) -> "exports?#{toShim}"
filenameRegex = new RegExp "^#{fileName}$"
if _.isString toShim
loader = _makeGlobalLoader toShim
{test: filenameRegex, loader: loader}
# Shortcut for creating loaders for shimming modules.
# Key is file/module name
# Value is variable to expose
shim = {
'3rdparty/swipe': 'Swipe'
}
extraLoaders = _.map shim, makeLoaderFromShim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment