Gruntfile.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* global require, module, process */
  2. 'use strict';
  3. module.exports = function(grunt) {
  4. // Project configuration.
  5. grunt.initConfig({
  6. pkg: grunt.file.readJSON('package.json'),
  7. meta: {
  8. banner: '/**\n' +
  9. ' * <%= pkg.description %>\n' +
  10. ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
  11. ' * @link <%= pkg.homepage %>\n' +
  12. ' * @author <%= pkg.author %>\n' +
  13. ' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
  14. ' */\n'
  15. },
  16. dirs: {
  17. dest: 'dist'
  18. },
  19. concat: {
  20. options: {
  21. banner: '<%= meta.banner %>'
  22. },
  23. dist: {
  24. src: ['src/*.js'],
  25. dest: '<%= dirs.dest %>/<%= pkg.name %>.js'
  26. }
  27. },
  28. uglify: {
  29. options: {
  30. banner: '<%= meta.banner %>'
  31. },
  32. dist: {
  33. src: ['<%= concat.dist.dest %>'],
  34. dest: '<%= dirs.dest %>/<%= pkg.name %>.min.js'
  35. }
  36. },
  37. jshint: {
  38. files: ['Gruntfile.js', 'src/*.js', 'test/unit/*.js'],
  39. options: {
  40. curly: false,
  41. browser: true,
  42. eqeqeq: true,
  43. immed: true,
  44. latedef: true,
  45. newcap: true,
  46. noarg: true,
  47. sub: true,
  48. undef: true,
  49. boss: true,
  50. eqnull: true,
  51. expr: true,
  52. node: true,
  53. globals: {
  54. exports: true,
  55. angular: false,
  56. $: false
  57. }
  58. }
  59. },
  60. // watch: {
  61. // files: '<config:jshint.files>',
  62. // tasks: 'default'
  63. // },
  64. karma: {
  65. test: {
  66. options: {
  67. reporters: ['dots'],
  68. singleRun: true
  69. }
  70. },
  71. options: {
  72. configFile: 'test/karma.conf.js'
  73. }
  74. }
  75. });
  76. // Load the plugin that provides the "jshint" task.
  77. grunt.loadNpmTasks('grunt-contrib-jshint');
  78. // Load the plugin that provides the "concat" task.
  79. grunt.loadNpmTasks('grunt-contrib-concat');
  80. // Load the plugin that provides the "uglify" task.
  81. grunt.loadNpmTasks('grunt-contrib-uglify');
  82. grunt.loadNpmTasks('grunt-contrib-connect');
  83. // Load the plugin that provides the "watch" task.
  84. //grunt.loadNpmTasks('grunt-contrib-watch');
  85. // Default task.
  86. grunt.registerTask('default', ['test']);
  87. // Test tasks.
  88. grunt.registerTask('test', ['jshint', 'karma:test']);
  89. grunt.registerTask('test-server', ['karma:server']);
  90. // Build task.
  91. grunt.registerTask('build', ['test', 'concat', 'uglify']);
  92. // run devserver
  93. grunt.registerTask('webserver', ['connect:devserver']);
  94. // Provides the "karma" task.
  95. grunt.registerMultiTask('karma', 'Starts up a karma server.', function() {
  96. var done = this.async();
  97. require('karma').server.start(this.options(), function(code) {
  98. done(code === 0);
  99. });
  100. });
  101. };