Giter Club home page Giter Club logo

grunt-mincer's Introduction

Build Status Dependency Status NPM version

grunt-mincer

Use mincer to concatenate your sources.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-mincer

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-mincer');

Documentation

Mincer is a multi task, meaning that grunt will automatically iterate over all mince targets if a target is not specified.

Overview

Inside your grunt.js file, add a section named mince.

Parameters

src string

Name of the file to be processed by mincer. It probably contains one or more mincer require directives. If source is not specified your target name with .js suffix will be used.

dest string

Output file: this is where mincer is going to dump your concatenated sources.

destDir string

If dest is not specified destDir and the name of your target are used to determine the name of the output file: path.join(destDir, target + '.js')

include string|array

List of directories that are added to mincer load path. If you have only one directory it can be specified as a single string.

helpers object

Use to define helpers functions for EJS module. You can preprocess any resource with EJS as long as you use ejs extension.

engines object

Object with configuration options for each mincer engine.

configure function(mincer)

Optional configure function that is called before before compile phase: allows for direct access to mincer object.

Config Examples

There are couple of formats you can use to configure mincer task.

'mince': {
  'main': {
    include: ['src', 'module/src'],
    src: 'main.js',
    dest: 'build/main.js'
  }
}

You can skip src if it has the same basename as your target:

'mince': {
  'main': {
    include: ['src', 'module/src'],
    dest: 'build/main.js'
  }
}

You can specify destDir instead of dest if your output file has the same basename as your target:

'mince': {
  'main': {
    include: ['src', 'module/src'],
    destDir: 'build'
  }
}

And if you only have one include directory you can specify it as string:

'mince': {
  'main': {
    include: 'src',
    destDir: 'build'
  }
}

You can use different format for each target.

You can configure Mincer engines: this configures CoffeeEngine to use bare compilation option, and instructs StylusEngine to use nib.

'mince': {
  'main': {
    include: 'src',
    destDir: 'build',
    engines: {
      'Coffee': { bare: true },
      'Stylus': function(stylus) {
        stylus.use(require('nib')());
      }
    }
  }
}

You can also define EJS helpers in your gruntfile:

'mince': {
  'main': {
    include: 'src',
    src: 'main.js.ejs',
    destDir: 'build',
    helpers: {
      version: function() { return "3.2.1"; }
    }
  }
}

To access Mincer directly used configure option:

'mince': {
  'main': {
    include: 'src',
    destDir: 'build',
    configure: function(mincer) {
      // call any mincer functions here
      mincer.logger.use({
        error: function(msg) {
          // set up special error logger
        }
      });
    }
  }
}

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

  • grunt-mincer 0.2 is compatible with grunt 0.3
  • grunt-mincer 0.3 and newer is compatible with grunt 0.4

See History.md

License

Copyright (c) 2012 (pirxpilot) Damian Krzeminski Licensed under the MIT license.

grunt-mincer's People

Contributors

awmckinley avatar inossidabile avatar pirxpilot avatar stah avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.