• function

config

 

steal.config( configOptions )

Configures the behavior of steal. For example:

steal.config({
  map: {
    "*": {
      "jquery/jquery.js" : "jquery",
      "can/util/util.js": "can/util/jquery/jquery.js"
    }
  },
  paths: {
    "jquery": "can/lib/jquery.1.8.3.js",
  },
  shim : {
    jquery: {
      exports: "jQuery"
    }
  },
  ext: {
    js: "js",
    css: "css",
    less: "steal/less/less.js",
    coffee: "steal/coffee/coffee.js",
  }
});

This sets the map, paths, shim, and ext.

steal.config(optionName)

Returns a configuration option value. Example:

steal.config("env") //-> "development"

steal.config(optionName, optionVal)

Configures a specific option value. Example:

steal.config("env","production")

Steal supports the following configuration options:

  • map - maps ids passed to steal to another id.
  • paths - maps ids to a specific path.
  • shim - used to support libraries that don't use steal.
  • ext - specifies a dependency to load for specific extensions
  • startId - the first module to load
  • root - the root folder where everything is loaded from
  • types - types used to load modules
  • env - the enviornement: "development" or "production"
  • loadProduction - load the production script in production environment
  • amd - turn on AMD support.
  • completed - tells steal that a dependency has already been loaded.

Alternative methods of setting config options

After steal.js is loaded and run, you can call steal.config anywhere. However, after steal.js loads, it automatically loads stealconfig.js before it loads anything else. stealconfig.js is the best place to configure settings that should be applied to all projects. But, there are other ways of calling steal.config.

Set startFile and env in the script tag

You can set startFile and env the queryparams of steal like:

<script src='../steal/steal.js?STARTFILE,ENV'>
</script>

For example:

<script src='../steal/steal.js?cookbook,production'>
</script>

If you load steal/steal.production.js the environment defaults to production:

<script src='../steal/steal.production.js?cookbook'>
</script>

A steal object that exists before steal.js is loaded

If a steal object exists before steal.js is loaded, steal will internally call steal.config with that object. For example:

<script>
steal = {
  completed: "myapp/production.css"
}
</script>
<script src='../steal/steal.production.js,myapp'>
</script>

Locating StealJS and other libraries outside the root folder.

Its common desire to want steal and other projects in some shared folder and the application code somewhere else. For example:

shared/
    steal/
    can/
    stealconfig.js
apps/
    myapp/
      myapp.js

This is possible by changing steal.config.root to point apps and
steal.config.paths to point to the shared location. For example, the following in stealconfig.js will work for the case above:

paths: {
  "can/": "../shared/can/",
  "steal/" : "../shared/steal/",
},
root: steal.config('root').join('../apps')

Signatures

steal.config()

Returns all configured properties. For example:

steal.config().root //-> URI

steal.config(propertyName)

Returns a single configured property value. For example:

steal.config("root") //-> URI

steal.config(properties)

Configures multiple properties at once. For example:

steal.config({root: "path/to/root"})