Navigator Prefabricating Marinates

    grunt-require-dir

    0.3.0 • Public • Published

    grunt-require-dir

    Task to build a requirejs AMD module out of a directory of files.

    Getting Started

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

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

    grunt.loadNpmTasks('grunt-require-dir');

    Config

    • require-dir
      • src : Your source files to include. Should all be under one common directory
      • baseDir : The local base directory prefix, removed from the source file paths (optional)
      • prefixDir : The new directory path to place in front of the source file paths (optional)
      • dest : The destination AMD file
      • plugin : The requirejs plugin to prefix the files with (optional). Useful for templates.
    'require-dir' : {
      all : {
        plugin    : 'tpl',
        src       : 'test/fixtures/texttree/**/*.tmpl',
        baseDir   : 'test/fixtures/texttree/',
        prefixDir : 'customDir/',
        dest      : 'test/fixtures/texttree.js'
      }
    },

    Example output

    Given the config above, and the file tree below

    |_ /fixtures
    | |_ /texttree
    | | |_ /A
    | | | |_ one.tmpl
    | | | |_ two.tmpl
    | | |_ bar.tmpl
    | | |_ foo.tmpl
    | | |_ unwanted.ext
    

    Running grunt require-dir (or grunt require-dir:all), you will get a file in test/fixtures/texttree.js with the contents

    define(function(require){
      return {
      'A' : {
        'one' : require("tpl!customDir/A/one.tmpl"),
        'two' : require("tpl!customDir/A/two.tmpl")
      },
      'bar' : require("tpl!customDir/bar.tmpl"),
      'foo' : require("tpl!customDir/foo.tmpl")
      };
    });

    Release History

    0.3.0 First public release

    License

    Copyright (c) 2012 Jarrod Overson
    Licensed under the MIT license.

    Keywords

    none

    Install

    npm i grunt-require-dir

    DownloadsWeekly Downloads

    1

    Version

    0.3.0

    License

    none

    Last publish

    Collaborators

    • jsoverson