| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2013 The Polymer Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style | |
| 4 * license that can be found in the LICENSE file. | |
| 5 */ | |
| 6 module.exports = function(grunt) { | |
| 7 // Recursive module builder: | |
| 8 var path = require('path'); | |
| 9 function readManifest(filename, modules) { | |
| 10 modules = modules || []; | |
| 11 var lines = grunt.file.readJSON(filename); | |
| 12 var dir = path.dirname(filename); | |
| 13 lines.forEach(function(line) { | |
| 14 var fullpath = path.join(dir, line); | |
| 15 if (line.slice(-5) == '.json') { | |
| 16 // recurse | |
| 17 readManifest(fullpath, modules); | |
| 18 } else { | |
| 19 modules.push(fullpath); | |
| 20 } | |
| 21 }); | |
| 22 return modules; | |
| 23 } | |
| 24 | |
| 25 // Karma setup: | |
| 26 var browsers; | |
| 27 (function() { | |
| 28 try { | |
| 29 var config = grunt.file.readJSON('local.json'); | |
| 30 if (config.browsers) { | |
| 31 browsers = config.browsers; | |
| 32 } | |
| 33 } catch (e) { | |
| 34 var os = require('os'); | |
| 35 browsers = ['Chrome', 'Firefox']; | |
| 36 if (os.type() === 'Darwin') { | |
| 37 browsers.push('ChromeCanary'); | |
| 38 } | |
| 39 if (os.type() === 'Windows_NT') { | |
| 40 browsers.push('IE'); | |
| 41 } | |
| 42 } | |
| 43 })(); | |
| 44 grunt.initConfig({ | |
| 45 karma: { | |
| 46 options: { | |
| 47 configFile: 'conf/karma.conf.js', | |
| 48 keepalive: true, | |
| 49 browsers: browsers | |
| 50 }, | |
| 51 buildbot: { | |
| 52 browsers: browsers, | |
| 53 reporters: ['crbot'], | |
| 54 logLevel: 'OFF' | |
| 55 }, | |
| 56 ShadowDOM: { | |
| 57 browsers: browsers | |
| 58 } | |
| 59 }, | |
| 60 concat: { | |
| 61 ShadowDOM: { | |
| 62 src: readManifest('build.json'), | |
| 63 dest: '../lib/shadow_dom.debug.js', | |
| 64 nonull: true | |
| 65 } | |
| 66 }, | |
| 67 uglify: { | |
| 68 ShadowDOM: { | |
| 69 options: { | |
| 70 compress: { | |
| 71 // TODO(sjmiles): should be false by default (?) | |
| 72 // https://github.com/mishoo/UglifyJS2/issues/165 | |
| 73 unsafe: false | |
| 74 } | |
| 75 //compress: true, Xmangle: true, beautify: true, unsafe: false | |
| 76 }, | |
| 77 files: { | |
| 78 '../lib/shadow_dom.min.js': ['../lib/shadow_dom.debug.js'] | |
| 79 } | |
| 80 } | |
| 81 }, | |
| 82 | |
| 83 yuidoc: { | |
| 84 compile: { | |
| 85 name: '<%= pkg.name %>', | |
| 86 description: '<%= pkg.description %>', | |
| 87 version: '<%= pkg.version %>', | |
| 88 url: '<%= pkg.homepage %>', | |
| 89 options: { | |
| 90 exclude: 'third_party', | |
| 91 paths: '.', | |
| 92 outdir: 'docs', | |
| 93 linkNatives: 'true', | |
| 94 tabtospace: 2, | |
| 95 themedir: '../docs/doc_themes/simple' | |
| 96 } | |
| 97 } | |
| 98 }, | |
| 99 pkg: grunt.file.readJSON('package.json') | |
| 100 }); | |
| 101 | |
| 102 // plugins | |
| 103 grunt.loadNpmTasks('grunt-contrib-concat'); | |
| 104 grunt.loadNpmTasks('grunt-contrib-uglify'); | |
| 105 grunt.loadNpmTasks('grunt-contrib-yuidoc'); | |
| 106 grunt.loadNpmTasks('grunt-karma-0.9.1'); | |
| 107 | |
| 108 // tasks | |
| 109 grunt.registerTask('default', ['concat', 'uglify']); | |
| 110 grunt.registerTask('minify', ['concat', 'uglify']); | |
| 111 grunt.registerTask('docs', ['yuidoc']); | |
| 112 grunt.registerTask('test', ['karma:ShadowDOM']); | |
| 113 grunt.registerTask('test-buildbot', ['karma:buildbot']); | |
| 114 }; | |
| OLD | NEW |