grunt-autowrap
grunt task plugin auto wrap exports or amd for js or coffee
Last updated 7 years ago by vontio .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install grunt-autowrap 
SYNC missed versions from official npm registry.

grunt-autowrap

auto exports wrap for js or coffee (currently exports based on filenames)

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-autowrap --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-autowrap');

The "autowrap" task

Overview

In your project's Gruntfile, add a section named autowrap to the data object passed into grunt.initConfig().

grunt.initConfig({
  autowrap: {
      testJs:{
        options: {
          exports:true,
          join: true,
          wrap: true,
          ext: 'js',
        },
        files: {
          'tmp/testJs.js': ['test/fixtures/A.js', 'test/fixtures/B.js'],
        },
      },
      testCoffee:{
        options: {
          exports:true,
          join: true,
          wrap:true,
          ext: 'coffee',
          coffee:true,
        },
        files: {
          'tmp/testCoffee.js': ['test/fixtures/*.coffee'],
        },
      },
    },
})

Options

options.exports

Type: boolean Default value: false

exports symbol.

options.join

Type: boolean Default value: false

concatenate files before processing.

options.wrap

Type: boolean Default value: false

add a wrapper function.

options.ext

Type: String Default value: js

source file extension.

options.coffee

Type: boolean Default value: false

compile coffee.

options.separator

Type: String Default value: "\n"

separator used to join files.

Usage Examples

exports concat and wrap js files

grunt.initConfig({
  autowrap: {
    testJs:{
      options: {
        exports:true,
        join: true,
        wrap: true,
        ext: 'js',
      },
      files: {
        'tmp/testJs.js': ['test/fixtures/A.js', 'test/fixtures/B.js'],
      },
    },
  },
})

exports and wrap coffee files

grunt.initConfig({
  autowrap: {
    testCoffee:{
      options: {
        exports:true,
        join: true,
        wrap:true,
        ext: 'coffee',
        coffee:true,
      },
      files: {
        'tmp/testCoffee.js': ['test/fixtures/*.coffee'],
      },
    },
  },
})

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.

Release History

0.1.0 exports based on filename

Current Tags

  • 0.3.0                                ...           latest (7 years ago)

3 Versions

  • 0.3.0                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 3
Dependencies (2)
Dev Dependencies (6)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |