Wraps .coffee and .js files into CommonJS modules for client-side usage.
Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-wrap-commonjs --save-dev
Then add this line to your project's Gruntfile.coffee
:
grunt.loadNpmTasks 'grunt-wrap-commonjs'
You need a require.register
function in the scope where you add the wrapped files. It's recommended to use commonjs-require for this purpose.
Configure which files to be copied in your initConfig
:
grunt.initConfig
# ... other configs
# wrap my modules with define
commonjs:
modules:
cwd: 'assets/'
src: ['**/*.coffee', '**/*.js']
dest: 'dist/'
# ... other configs
pathReplace
Allows you to set filterer function for module names, for example, change all app/file to file. Default: false
pathReplace: (path) ->
path.replace(/^app\//, '')
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
MIT
Copyright (c) 2013-2014 efa GmbH Copyright (c) 2012-2013 Christopher Rogers, Team Delicious, AVOS Systems Inc., Derek Petersen