Skip to content

Instantly share code, notes, and snippets.

@designeng
Created September 24, 2014 14:01
Show Gist options
  • Save designeng/45504f810e2b99ad0943 to your computer and use it in GitHub Desktop.
Save designeng/45504f810e2b99ad0943 to your computer and use it in GitHub Desktop.
requirejs hook for additiional file processing
onBuildWrite: (moduleName, path, contents) ->
if path.match "/bower_components/"
pathFragments = path.split "/"
index = 0
libName = undefined
for fragment in pathFragments
if fragment is "bower_components"
libName = pathFragments[index + 1]
console.log "libName::::", libName
break
else
index++
contents = 'define(["another/id"], function () {});'
return contents
@designeng
Copy link
Author

Infrastructure modules can be filtered by this hook.
We can track which parts of the library was loaded (inserted into the page header, as variant) and so on.

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