Skip to content

Wrap CoffeeScript or JavaScript into a CommonJS compatible require definition

License

Notifications You must be signed in to change notification settings

blake-newman/grunt-wrap-commonjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-wrap-commonjs

Wraps .coffee and .js files into CommonJS modules for client-side usage.

Getting Started

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'

CommonJS Require

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.

Documentation

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

Configuration

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\//, '')

Contributing

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.

License

MIT

Copyright (c) 2013-2014 efa GmbH Copyright (c) 2012-2013 Christopher Rogers, Team Delicious, AVOS Systems Inc., Derek Petersen

About

Wrap CoffeeScript or JavaScript into a CommonJS compatible require definition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •