grunt-wrap-commonjs

0.4.4 • Public • Published

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

Package Sidebar

Install

npm i grunt-wrap-commonjs

Weekly Downloads

1

Version

0.4.4

License

MIT

Last publish

Collaborators

  • efacilitation