blob: 801b48ad1237c93b873a3159ab9c6a2c7807886e [file] [log] [blame]
/*
* Copyright 2013 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
module.exports = function(grunt) {
// Recursive module builder:
var path = require('path');
function readManifest(filename, modules) {
modules = modules || [];
var lines = grunt.file.readJSON(filename);
var dir = path.dirname(filename);
lines.forEach(function(line) {
var fullpath = path.join(dir, line);
if (line.slice(-5) == '.json') {
// recurse
readManifest(fullpath, modules);
} else {
modules.push(fullpath);
}
});
return modules;
}
// Karma setup:
var browsers;
(function() {
try {
var config = grunt.file.readJSON('local.json');
if (config.browsers) {
browsers = config.browsers;
}
} catch (e) {
var os = require('os');
browsers = ['Chrome', 'Firefox'];
if (os.type() === 'Darwin') {
browsers.push('ChromeCanary');
}
if (os.type() === 'Windows_NT') {
browsers.push('IE');
}
}
})();
grunt.initConfig({
karma: {
options: {
configFile: 'conf/karma.conf.js',
keepalive: true,
browsers: browsers
},
buildbot: {
browsers: browsers,
reporters: ['crbot'],
logLevel: 'OFF'
},
ShadowDOM: {
browsers: browsers
}
},
concat: {
ShadowDOM: {
src: readManifest('build.json'),
dest: '../lib/shadow_dom.debug.js',
nonull: true
}
},
uglify: {
ShadowDOM: {
options: {
compress: {
// TODO(sjmiles): should be false by default (?)
// https://github.com/mishoo/UglifyJS2/issues/165
unsafe: false
}
//compress: true, Xmangle: true, beautify: true, unsafe: false
},
files: {
'../lib/shadow_dom.min.js': ['../lib/shadow_dom.debug.js']
}
}
},
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options: {
exclude: 'third_party',
paths: '.',
outdir: 'docs',
linkNatives: 'true',
tabtospace: 2,
themedir: '../docs/doc_themes/simple'
}
}
},
pkg: grunt.file.readJSON('package.json')
});
// plugins
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.loadNpmTasks('grunt-karma-0.9.1');
// tasks
grunt.registerTask('default', ['concat', 'uglify']);
grunt.registerTask('minify', ['concat', 'uglify']);
grunt.registerTask('docs', ['yuidoc']);
grunt.registerTask('test', ['karma:ShadowDOM']);
grunt.registerTask('test-buildbot', ['karma:buildbot']);
};