Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Configuration

Nils P. Ellingsen edited this page · 63 revisions

All configuration options are documented with examples here. YMMV.

"Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it should be precise and comprehensive." -- http://semver.org

  • Options marked with are options not fully implemented
  • Options marked with are options that's not implemented yet.

Table of Contents

  1. Default Configuration file
  2. Configuration variables
  3. More example configuration files

Default configuration file

This is the current default configuration file.

{
  "project": {
    "details": {
      "name": "<folder name>",
      "homepage": "",
      "author": ""
    },
    "environment": {
      "root" : "<folder name>",
      "abs_path": "",
      "web_root": "",
      "port": 8000,
      "host": "localhost",
      "home_file": "index.*"
    },
    "options" : {
      "watch_config": false
    }
  },
  "build": {
    "js": "js/src/",
    "min": {
      "dest": "js/min/output.min.js"
    },
    "dist": "js/dist/",
    "tmpl": {
      "src": "js/mustache/",
      "dest": "js/src/templates.js"
    },
    "lint" : {},
    "docs" : {
      "dest" : "js/docs/"
    },
    "css" : {
      "src" : "css/src/",
      "dist" : "css/dist/style.css"
    },
    "test": {
      "suites": {
        "nodeunit" : {
          "src": "js/test/nodeunit/**/*.js"
        }
      }
    },
    "options": {
      "watch" : true,
      "verbose": true,
      "testsOnWatch" : false,
      "linting": true,
      "force" : false
    }
  },
  "proxy": {
    "resources" : [],
    "options": {
      "verbose": true,
      "port" : 80
    }
  },
  "fileserver" : {
    "host" : "localhost",
    "port" : 8080
  },
  "options": {
    "verbose": true,
    "logToFile": false,
    "scripture": true
  }
}

⬆ Go to the TOC

Configuration variables

Documented below are all available configuration variables.

project

Settings regarding the project you are working on.

project.details

Project details.

project.details.name

  • Type: String
  • Defaults: <project folder name>

The name of the current project. Defaults to folder name if no name is set.

project.details.homepage

  • Type: String

Website for the project you are working on.

project.details.author

  • Type: String|Array

Author of the project. Can be a String or an Array with objects.

Examples

"author" : "John Hancock"
"author" : [{
    "name" : "Jon Hancock",
    "email" : "jon.hancock@themovies.com",
    "homepage" "http://google.com"
  },{
    "name" : "Will Ferrel",
    "email" : "will.ferrel@themovies.com",
    "homepage" "http://google.com"
  }]

⬆ Go to the TOC

project.environment

Environment settings.

project.environment.root

  • Type: String
  • Defaults: <project folder name>

The root folder of your project.

project.environment.abs_path

  • Type: String

Absolute path to your project.

project.environment.web_root

  • Type: String

The webroot of your project.

Example

"environment":{
  "web_root": "src/main/webapp/"
}

project.environment.port

  • Type: Integer
  • Defaults: 8090

Your current project environment port. This is used to relay non-matching proxy requests to.

project.environment.host

  • Type: String
  • Defaults: localhost

Your environment host. This is used for the static fileserver module and the live reload module.

project.environment.home_file

  • Type: String
  • Defaults: index.*

Your projects home URI. Usually index.html or /. Where you start your project. This can either be just a filename, or a relative URI.

⬆ Go to the TOC

project.options

A set of options for your project. Not to be confused with options which are options related to patsy itself.

project.options.watch_config

Type: Boolean Defaults: false

Toggle to let patsy know if he should monitor your projects config file for changes and reload it if the file has changed.

Note: This will only reload options changed for the modules. If global settings, for example, the global options object is changed, reloading the config while patsy is running will not affect the global options. This also applies to the project settings object.

⬆ Go to the TOC

build

Settings regarding the build system.

build.js

  • Type: String
  • Defaults: js/src/

Path to your JavaScript files. Defaults to js/src/ if not set. This path is used by The GruntJS module to locate the files for build.

build.min

Settings for the JavaScript minification feature.

Example configuration

"min": {
  "dest": "js/min/foo.core.js",
  "options" : {
    "sourceMap" : "js/dist/maps/sourcemap.js",
    "mangle" : false
  }
}

build.min.dest

  • Type: String
  • Defaults: js/min/output.min.js

Filepath to your minified js file, as in, where the minified file patsy generate it to. Defaults to js/min/output.min.js if not set. If build.dist is set, build.dist takes presedence over this option.

build.min.options

  • Type: Object

Options for Uglify task. This is passed to UglifyJS via grunt-contrib-uglify. See documentation of grunt-contrib-uglify for full set of possible options.

build.dist

Path to baked files, where all the baked files are put. The files generated here are intended to be included in your webpage when you run your project. Defaults to js/dist/ if not set. If this option is left blank, the minification module grunt-contrib-uglify will use build.min.dest instead.

build.dist.options

  • Type: Object

Set of options for the js baking. This is passed to the relevant build system plugin if set. See documentation of the current grunt plugin for full list of options to pass.

build.templ

Settings for the template feature.

build.templ.src

  • Type: String
  • Defaults: js/mustache/

Path to your template files. Defaults to js/mustache/ if not set.

build.templ.options

  • Type: Object

Set of options for the template baking. This is passed to the relevant build system plugin if set. See documentation of the current grunt plugin for full list of options to pass.

Example

"tmpl": {
  "src": "js/mustache/",
  "options" : {
    "prefix" : "$B.extend({ templates: ",
    "postfix" : "});"
  }
}

This will generate following string in templates.js:

$B.extend({templates: <your generated template code here>});

For further reading on how the pre/post-fix variable is used, check the grunt-mustache documentation.

build.lint

Settings for linting functionality.

build.lint.options

  • Type: Object

Set of options for the linting. This is passed to the relevant build system plugin if set. See documentation of the current grunt plugin for full list of options to pass.

build.css

Settings for CSS baking functionality.

Example

"css" : {
  // This could be an Array of paths with glob patterns, a String directory path or a String filepath.
  "src" : "css/src/less/main.less",
  // This is only needed if you have options set to compile, or your src contains *.less files
  "dest" : "css/dist/style.css",
  "options" : {
    "compile" : true,
    "compress" : true
  }
},

Logic in Gruntfile.js

recess: {
  dist: {
    src: config.build.css.src || [
      '<%= basepath %><%= app.build.css.src %>**/*.css',
      '<%= basepath %><%= app.build.css.src %>**/*.less'
    ],
    dest: '<%= basepath %><%= app.build.css.dest %>',
    options: config.build.css.options || { compile: true }
  }
}

build.css.src

  • Type: String|Array
  • Defaults: css/src/

Path to your css directory containing your *.css and/or *.less files. Defaults to css/src/ if not set. This could be an Array of paths with glob patterns, a String directory path or a String filepath.

build.css.dest

  • Type: String
  • Defaults: css/dist/style.css

Path where your compiled *.less-files are baked into. Must be a filepath. Defaults to css/dist/style.css if not set. dest is only needed when the option build.css.options.compile is set to true or if your build.css.src contains any *.less-files.

build.css.options

  • Type: Object

Set of options for the CSS baking. This is passed to the relevant build system plugin if set. See documentation of the current grunt plugin for full list of options to pass.

build.css.options.compile

  • Type: Boolean
  • Defaults: true

Compile all found *.less and *.css files found.

build.css.options.compress

  • Type: Boolean
  • Defaults: false

Minify CSS files.

build.docs

Settings for the documentation generation.

build.docs.dest

  • Type: String
  • Defaults: js/docs/

Path to generated documentation. Defaults to js/docs/. Per now, the default generated output file is named api.html.

Issue for passing options to dox-foundation -> dox can be found here: https://github.com/punkave/grunt-dox/issues/3

build.docs.options

  • Type: Object

Set of options for the documentation generation. This is passed to the relevant build system plugin if set. See documentation of the current grunt plugin for full list of options to pass.

build.test

Settings for testing.

build.test.suites

  • Type: String
  • Defaults: see description below

What test suite do you want to use?

Defaults

{
  "nodeunit" : {
    "src": "js/test/nodeunit/"
}

Example 1

"test": {
  "suites": {
    "jasmine" : {
      "src": "js/test/jasmine/**/*.js"
    },"qunit" : {
      "src": "js/test/qunit/**/*.html",
      "options": {
        "timeout": 10000,
        "--cookies-file": "misc/cookies.txt"
      }
    },"nodeunit" : {
      "src": "js/test/nodeunit/**/*.js"
    }
  }
}

Example 2

"test": {
      "suites": {
        "nodeunit": {
          "src": "js/test/nodeunit/**/*.js"
        },
        "qunit": {
          "all": {
            "options" : {
              "urls" : ["http://localhost/js/test/qunit/test.html"]
            }
          }
        },
        "jasmine" : {
          "sfl-client" : {
            "src": ["js/dist/**/*.js","pm-js/js/min/top_menu.js"],
            "options" : {
              "host" : "http://localhost/",
              "template" : "js/test/jasmine/fixtures/sfl.tmpl",
              "specs" : "js/test/jasmine/test.js",
              "outfile" : "_SpecRunner.html"
            }
          }
        }
      }
    }

build.test.suites.<suite>.src

  • Type: String

Path to your JavaScript test files. Patsy looks for *.js or *.html to be used in the given harness. Specs and fixtures used by other suites are passed with the options variable to the relevant test suite plugin.

build.test.suites.<suite>.options

  • Type: Object

Set of options for the test suite. This is passed to the relevant build system plugin if set. See documentation of the current grunt plugin for full list of options to pass.

We currently full support node-unit and QUnit as test suits. Full support for Jasmine is yet to come.

build.options

  • Type: Object

Set of options for the build system.

build.options.watch

  • Type: Boolean
  • Defaults: true

Toggle if you want patsy to monitor file changes. Defaults to ´true´.

Example

"build" : {
  "options" : {
    "watch" : true
  }
}

build.options.verbose

  • Type: Boolean
  • Defaults: true

Set output to verbose. Defaults to true.

build.options.testsOnWatch

  • Type: Boolean
  • Defaults: false

Toggle for running tests when watching files. Defaults to false.

build.options.linting

  • Type: Boolean
  • Defaults: true

Toggle for linting JavaScript files. Defaults to true.

build.options.force

  • Type: Boolean
  • Defaults: false

Toggle for sending the --force flag to the build system. Defaults to false if not set.

⬆ Go to the TOC

proxy

Settings regarding the proxy module

proxy.resources

  • Type: Array

An Array with objects of URL and required parameters/headers for the API's intended for use.

Example

"proxy": {
  "resources": [{
    "path" : "/api/oauth/token",
    "pass"      : "http://beezwax:1500/rest-api/oauth/servicetoken"
  },{
    "path" : "/model/person/",
    "pass"      : "http://alt-stb-002:12000/database/sources/model/person/",
    "headers"       : {
      "foo": "bar"
    }
  }],
  "options": {
    "verbose": true,
    "headers"       : {
      "foo": "baz",
      "saefg": "boyah"
    }
  }
}

Currently, we do only support http to http forwarding.

proxy.resources[].path

  • Type: String

On what path are we setting up the proxy for? Both resources.path and resources.pass MUST have a trailing slash or not! If resources.path got a trailing slash, resources.pass must have a trailing slash.

Example

"path": "/path/to/resource"

proxy.resources[].pass

  • Type: String

A string containg the full URL to pass to. Both resources.path and resources.pass MUST have a trailing slash or not! If resources.path got a trailing slash, resources.pass must have a trailing slash.

Example

"pass": "http://stage.domain:2310/path/to/resource"

proxy.resources[].headers

  • Type: Boolean|Object
  • Defaults: false

Custom headers to send with the proxy redirection. Defaults to the global proxy options if not set, if set, this option is extended with the global options for proxy.

proxy.options

  • Type: Object

Set of options for the proxy module.

proxy.options.verbose

  • Type: Boolean
  • Defaults: true

Toggle option. Defaults to true.

proxy.options.headers

  • Type: Object

Set headers to be sent on all requests.

proxy.options.port

  • Type: Integer
  • Default: 80

Port the proxy listens to. Defaults to 80 if not set.

⬆ Go to the TOC

fileserver

File server settings.

fileserver.host

  • Type: String
  • Default: localhost

Hostname for static fileserver. Defaults to localhost if not set.

fileserver.port

  • Type: Ìnteger
  • Default: 8080

Port for static fileserver. Defaults to 8080 if not set.

⬆ Go to the TOC

options

  • Type: Object

Set of options for patsy. These are overriden if matching flag from CLI is used.

options.verbose

  • Type: Boolean
  • Defaults: true

Toggle option. Defaults to true.

options.logToFile

  • Type: Boolean
  • Defaults: false

Toggle option. Defaults to false.

options.scripture

  • Type: Boolean
  • Defaults: true

Toggle "Quest for The Holy Grail" scripture. Defaults to true.

⬆ Go to the TOC

More example configuration files

...

⬆ Go to the TOC

Something went wrong with that request. Please try again.