Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Grunt Task mantriDeps

Thanasis Polychronakis edited this page · 7 revisions

The mantriDeps task generates the dependency file deps.js. This file is required by the web application so it can operate in the development environment.

Options

The mantriDeps task has no requirements for options. If none are defined, the options would equal to:

mantriDeps: {
  target: {
    src: './',
    dest: './deps.js'
  }
}

dest

Type: string Default: deps.js

The file you wish the generated deps file to be saved at.

src

Type: string Default: ./

The source to scan for goog.provide and goog.require statements, essentialy the path to your web application.

The source must be a string representing an actual folder. It cannot be an array or use globbing patterns.

Be careful when defining a source. If the source is different from your document (web) root, you will need to define the documentroot using the root option.

root

Type: string Default: ./

The root option defines the Document (web) Root directory of your website. It is required if you define the source option.

Use Cases

There are typically two types of setups, one is where your project's root folder is the same as your web app. The other case being the opposite, your web root is in a subfolder. Identifying your use case is very important for the correct operation of the mantriDeps task.

Case 1: Your Project Root is Also The Document Root

In this case, it is not advisable to go with the mantriDeps default options. The default options would set the ./ as the folder to scan for .js files. The ./ folder is also your project folder which is quite possible that it includes a node_modules folder. This will most probably break the deps operation as .js files inside node_modules will certainly confuse the task.

To get past this problem you need to define a src and a root option. Assuming you have all your .js assets in the js/ folder here is how your config would look like:

mantriDeps: {
  options: {
    root: './'
  },
  target: {
    src: 'js',
    dest: './deps.js'
  }
}

This will instruct mantriDeps to scan for .js files inside the js folder but have the Document Root set to ./ which is also the Project's root.

Check out the Mantri todoMVC app that has the Project root same as the Document root.

Case 2: Your Document Root is in a Subfolder

That is typically the most common case, your whole Document Root exists under a certain folder inside your Project's root.

Assuming your document root is in folder static this should be your config:

mantriDeps: {
  target: {
    src: 'static'
  }
}

This will instruct mantriDeps to scan for .js files inside the static folder and save the generated deps.js file in static/deps.js.

Something went wrong with that request. Please try again.