node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

grunt-extract-required

grunt-extract-required

Build Status

A grunt task to extract commonly required modules in src files, and genenrate a JS code to use as a loader.

Using extract-required inside.

Usage

A example grunt task in Gruntfile.js :

 
  ...
 
  extract_required: {
    lib: {
      files: {
        'output/core-require.js' : [ 'lib/core/**/*.js' ]
      },
      options: {
        baseDir: 'lib/',
        ignore: [ './submodule/**/*' ],
        exposeToGlobal: true
      }
    }
  },
 
  ...
 

Options

options.baseDir

Specify a base directory to canonicalize relatively loaded module paths.

options.ignore

Specify a glob pattern or name of modules to ignore from the output.

options.exposeToGlobal

If you want to expose the generated loader function to global, set true (or custom global function name; by default it use require). Otherwise the function will be opened as a CommonJS-style module.