grunt-wrap-commonjs
Wrap CoffeeScript or JavaScript into a CommonJS compatible require definition
Last updated 6 years ago by efacilitation .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install grunt-wrap-commonjs 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.4.4                                ...           latest (6 years ago)

2 Versions

  • 0.4.4                                ...           6 years ago
  • 0.4.3                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (4)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |