Git Product home page Git Product logo

grunt-mootools-packager's Introduction

grunt-mootools-packager

Grunt task for MooTools Packager projects.

Getting Started

This plugin requires Grunt ~0.4.2

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-mootools-packager --save-dev

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

grunt.loadNpmTasks('grunt-mootools-packager');

The "packager" task

Overview

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

grunt.initConfig({
  packager: {
    options: {
      name: 'Core' // Package name. (todo: use package.json)
    },
    your_target: {
      // Target-specific file lists and/or options go here.
      'mootools-all.js': 'Source/**.js'
    },
  },
});

Options

options.strip

Type: String or Array<String|RegExp> Default value: false

A single, or multiple, strings or regexp to remove from the combined code.

options.separator

Type: String Default value: grunt.util.linefeed

The delimeter to join all the source files together.

options.callback

Type: Function

The function to be called when compilation is finished. The compiled content will passed as the first argument in the callback function.

options.noOutput

Type: Boolean

If true no files will be written. Defaults to false.

options.name

Type: String or Object

The package name. TODO: Use package.json.

The name of the package, or, if there are multiple packages being built, an object with the names and paths to their source files.

grunt.initConfig({
  packager: {
    options: {
      name: {
        Core: 'js/mootools-core',
        More: 'js/mootools-more'
      }
    },
    all: {
      'dest/mootools.js': 'Source/**.js',
    },
  },
});

options.ignoreYAMLheader

Type: Booelan Default value: false

Ignores the YAML headers for dependency loading.

options.only

Type: String or Array

The specific components or packages to compile (with their dependencies).

NOTE: You can specify the .only value in the .options and it will apply to all configurations globally, but you can also specify an .only value for each configuration. This allows you to build numerous libraries with specific requirements.

grunt.initConfig({
  packager: {
    options: {
      name: {
        Core: 'js/mootools-core',
        More: 'js/mootools-more'
      }
    },
    // all of both libraries
    all: {
      src: [
        'js/mootools-core/Source/**/*.js',
        'js/mootools-more/Source/**/*.js'
      ],
      dest: 'mootools.js'
    },
    // the Form.Validator component and its requirements
    formValidator: {
      src: [
        'js/mootools-core/Source/**/*.js',
        'js/mootools-more/Source/**/*.js'
      ],
      only: [
        'More/Form.Validator'
      ],
      dest: 'form.validator.js'
    },
    // all of the More package and its requirements
    allOfMore: {
      src: [
        'js/mootools-core/Source/**/*.js',
        'js/mootools-more/Source/**/*.js'
      ],
      only: [
        'More/*'
      ],
      dest: 'more.js'
    }
  },
});

options.exclude

Type: Array Syntax: ['PackageNameA/*'<, 'PackageNameB/*', ...>]

The specific dependencies packages to exclude from the compilation. For example, adding exclude: ['Core/*'] in the Gruntfile options would exclude all Core dependencies from output file.

grunt.initConfig({
  packager: {
    options: {
      name: {
        Core: 'js/mootools-core',
        More: 'js/mootools-more'
      }
    },
    // build only Core
    all: {
      src: [
        'js/mootools-core/Source/**/*.js',
      ],
      only: ['Core/*'],
      dest: 'mootools-core.js'
    },
    // the Form.Validator component and its requirements from
    // More, but none of the dependencies from Core
    formValidator: {
      src: [
        'js/mootools-core/Source/**/*.js',
        'js/mootools-more/Source/**/*.js'
      ],
      only: [
        'More/Form.Validator'
      ],
      exclude: [
        'Core/*'
      ],
      dest: 'form.validator.js'
    }
  },
});

Other Usage Examples

Default Options

grunt.initConfig({
  packager: {
    options: {
      name: 'Core'
    },
    all: {
      'dest/mootools.js': 'Source/**.js',
    },
  },
});

Strip Options

grunt.initConfig({
  packager: {
    options: {
      name: 'Core',
      strip: '.*compat'
    },
    all: {
      'dest/mootools.js': 'Source/**.js',
    },
  },
});

Build-Specific Options

grunt.initConfig({
  packager: {
    options: {
      name: 'Core'
    },
    all: {
      'dest/mootools.js': 'Source/**.js',
    },
    allWithoutCompat: {
      strip: '.*compat',
      src: 'Source/**.js',
      dest: 'mootools-no-compat.js'
    },
  },
});

grunt-mootools-packager's People

Contributors

anutron avatar gcheung55 avatar ibolmo avatar sergiocrisostomo 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.