paths

  • property
config.paths {Object<glob,glob>}  

Configure the location of a module or modules.

Object<glob,glob>

If a moduleName matches one of the keys of the paths config, it is located with at the value of the key.

If paths for @config, @dev, @traceur, [$css], [$less], "bundles/*" and "bundles/*.css" are not set, steal.js will provide default paths.

Use

paths can be configured with any of the approaches in config. It is used to provide the path of a module. You might use this if you install a module with a package manager, for example with npm:

"steal": {
    "paths": {
        "jquery": "node_modules/jquery/dist/jquery.js"
    }
}

Will map the the jquery module to where the JavaScript file is located in node_modules.

Wildcard paths

The * is used to denote wildcard paths. These allow substitution in cases where you want a common pattern for referring to module names. A common example of this would be a package where you want to load only certain modules and not the main module.

For example:

"steal": {
    "paths": {
        "lodash/*": "/js/lodash/*.js",
        "theme/*": "jquery-ui/themes/base/jquery.ui.*css"

    }
}

This would allow you to do:

import throttle from "lodash/functions/throttle"

to load only the throttle function.

See this issue on why css and other extensions have strange rules.

Default paths configured by steal

If the following paths are not specified, steal.js will use a default path according to the following rules:

  • @config - If steal.js is in ROOT/node_modules/steal/steal.js, @config defaults to ROOT/stealconfig.js; otherwise, it defaults to baseURL/stealconfig.js. Specifying @config will specify baseURL.
  • @dev - defaults to STEAL_BASE/steal/dev.js
  • @traceur - defaults to STEAL_BASE/traceur/traceur.js
  • [$css] - defaults to STEAL_BASE/steal/css.js
  • [$less] - defaults to STEAL_BASE/steal/less.js
  • "bundles/*" - defaults to "dist/bundles/*.js"
  • "bundles/*.css" - defaults to "dist/bundles/*css"

Note: STEAL_BASE is the parent folder of the steal folder.

Help us improve StealJS by taking our community survey