Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Snippet of Gruntfile.coffee code to wrap a number of json files and attach them to the namespace. Requires grunt-contrib-concat. More flexible than using some of the grunt json packages
concat:
json:
src: ['source/files/here.json']
dest: 'output/files/here.js'
options:
banner: "(function(namespace){\n'use strict'\nnamespace.json={};\n"
footer: "\n})(YOURNAMESPACEHERE)"
process: (src,filepath) ->
arr = filepath.split '/'
filename = arr[arr.length-1]
# Process the filename here to extract bits you need. E.g.:
name = filename.replace('.json','')
return "namespace.json['#{name}']=#{src};\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.