Before we replace standardSetup with our version which calls registerConnect we
save the previous method in an array.
registerConnect sets up two targets for the grunt-contrib-connect
task, which runs a basic file server. Two different targets are provided:
registerMocha pulls in grunt-mocha which uses phantomjs
and a custom bridge to run in-browser tests on the command line. You're
just responsible for the collection of urls to hit. You might consider using
the port 3001 urls available with the connect task above.
registerOptimizeLibrary uses grunt-requirejs to produce one concatenated file,
optimized and including source maps by default.
Sadly, preserveLicenseComments is incompatible with generateSourceMaps. So we've
opted for source maps.
registerOptimizeLibrary uses grunt-requirejs to produce both optimized
and unoptimized versions of a given library using the r.js optimizer.
If specified, standalone versions of that library can be produced as well
(using almond), resulting in four total files:
registerSauce pulls in the grunt-saucelabs package and sets up its subtask,
saucelabs-mocha with a number of defaults to make it easy. It pulls values from
'env.json' and 'package.json' in the current working directory, so if you run the
grunt command from another directory than the root of your project, you'll get
different behavior.
Note: by default this plugin uses
Sauce Connect to make local URLs
available to the Sauce Labs infrastructure. Set tunneled = false to disable that
behavior.
config.registerSauce({
// required
urls: [
'can be local URLs, since sauce connect is used'
],
// optional; defaults are:
username: 'SAUCE_USERNAME from env.json',
key: 'SAUCE_ACCESS_KEY from env.json',
testname: 'name from package.json',
build: 'version from package.json',
browsers: [
'a small subset of supported sauce labs platform that gives good coverage'
],
sauceConfig: {
// test results are available via their unique url to anyone who has it
public: 'share'
},
pollInterval: 750,
throttling: 2
});
Check ./sauce_platforms.html for more information on the sauce
platform subsets available. More information on options you can pass to
the grunt-saucelabs tasks
registerPreambleForDist installs a task called 'preamble-for-dist' which injects
project version/license/author information into the top of files in the dist folder. By
default, it applies to all javascript files under your project 'dist' directory.
It will attempt to load your project's 'package.json' by loading the file by that name
at process.cwd(). You can override this lookup by providing your own pkg object on
options. Otherwise, be careful where you run the grunt command.
grunt.registerPreambleForDist({
// this key will override package.json from disk
pkg: {
// these keys are required, either from pkg or from your package.json
name: 'project-name',
version: '1.4',
homepage: 'http://my.homepage',
author: 'Someone',
// optional; both contributor formats supported
contributors: [
'Person 1 <email>',
{name: 'Person', email: 'email'}
],
// only required if no LICENSE.txt is found and licenseContent not provided
license: 'a short name, like MIT'
},
// optional; the set of files to process
src: ['dist/js/public/*.js', 'dist/library.css'],
// optional; overrides LICENSE.text from working directory
licenseContent: 'complete license text',
// optional
comments: {
library1: 'Library 1 uses components from X, Y and X packages.',
'*': 'This project is a labor of love'
}
});
Note: keys in the comments object are regular expressions. If a file matches more
than one key, each message will be included.
mixin
Adds a set of new client-side development configuration methods to the GruntConfig class provided by
thehelp-project.