Skip to content

Configuration files

Stefan Prodan edited this page Aug 29, 2014 · 5 revisions

There are two formats currently supported for configuration files: JSON and XML (deprecated, will be removed in 3.0).

The JSON configuration is designed so that you can take your current require.js configuration object (if you already have one) and use it without having to modify it. Some advanced options will not be available this way.

The RequireJsNet.Examples project contains two example configurations (basic and complex).

A description of the available configuration options and what their effects are is provided below:

  • paths: Compatible with requirejs.js' paths object. The only difference is that you have the posibility of specifying a default bundle at a path level.

  • shim: Compatible with require.js' shim object. The only difference is that the init property that you can define when configuring require.js via javascript is not supported.

  • map: Compatible with require.js' map object.

  • bundles: Compatible with require.js' bundles object, though many of the features are not available.

The example below illustrates the possibilities that will work with the parser:

      "bundles": {
          "jqplot": [ "jquery", "jqplot" ], // all the items will have the "standard" compression level,
                                            // virtual will be false
                                            // the outputPath is computed using the bundle's id
          "jqueryBundle": {
              "virtual": "true",
              "items": [ "jquery" ]
           },
          "jqvalUnobtrusive": ["jquery-validate-unobtrusive", "jquery-validate"],
           "full": {
           "outputPath": "Bundles\\full.min.js",
              "items": [
                  {
                      "path": "bootstrap",
                      "compression": "none"
                  },
                  {
                      "path": "amplify",
                      "compression": "standard"
                  }
              ],
               "includes": ["jqueryBundle", "jqvalUnobtrusive", "jqValidate"]
          }
        }

For a better understanding of the various compressor options, see the compressor documentation.

  • autoBundles: used for defining autoBundles. Example:
       "autoBundles": {
         "full": {
            "outputPath": "bundles\\auto\\",  // note the trailing slash, 
                                              // otherwise it will be considered a 
                                              // filename and outputted as such
            "include": [
                {
                    "directory": "\\controllers\\Root\\"
                },
                {
                    "file": "jquery"
                }
            ]
       }

For a better understanding of the various autoCompressor options, see the autoCompressor documentation .