Gruntfile.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. module.exports = function(grunt) {
  2. 'use strict';
  3. var L = grunt.log.writeln;
  4. var BANNER = '/**\n' +
  5. ' * Open Sheet Music Display library <%= pkg.version %> built on <%= grunt.template.today("yyyy-mm-dd") %>.\n' +
  6. ' * Copyright (c) 2016 PhonicScore\n' +
  7. ' *\n' +
  8. ' * https://github.com/opensheetmusicdisplay/opensheetmusicdisplay\n' +
  9. ' */\n';
  10. grunt.initConfig({
  11. pkg: grunt.file.readJSON('package.json'),
  12. // Build output directories
  13. outputDir: {
  14. build: 'build',
  15. dist: 'dist'
  16. },
  17. // Browserify
  18. browserify: {
  19. dist: {
  20. src: ['typings/browser.d.ts', 'src/**/*.ts'],
  21. dest: '<%= outputDir.build %>/osmd.js'
  22. },
  23. debug: {
  24. src: ['typings/browser.d.ts', 'src/**/*.ts', 'test/**/*.ts'],
  25. dest: '<%= outputDir.build %>/osmd-debug.js',
  26. options: {
  27. browserifyOptions: {
  28. debug: true
  29. }
  30. }
  31. },
  32. options: {
  33. plugin: ['tsify']
  34. }
  35. },
  36. // Uglify
  37. /*uglify: {
  38. options: {
  39. compress: {
  40. drop_console: true
  41. }
  42. },
  43. my_target: {
  44. files: {
  45. 'build/osmd.js': ['src/input.js']
  46. }
  47. }
  48. },*/
  49. // TSLint setup
  50. tslint: {
  51. options: {
  52. configuration: 'tslint.json'
  53. },
  54. all: {
  55. src: ['<%= browserify.dist.src %>', '<%= browserify.debug.src %>']
  56. }
  57. },
  58. // TypeScript type definitions
  59. typings: {
  60. install: {}
  61. },
  62. docco: {
  63. src: ['src/**/*.ts'],
  64. options: {
  65. layout: 'linear',
  66. output: 'build/docs'
  67. }
  68. },
  69. // Settings for clean task
  70. clean: {
  71. options: {
  72. force: true
  73. },
  74. all: {
  75. src: [
  76. '<%= outputDir.build %>',
  77. '<%= outputDir.dist %>',
  78. '.tscache'
  79. ]
  80. }
  81. },
  82. });
  83. grunt.loadNpmTasks('grunt-browserify');
  84. grunt.loadNpmTasks('grunt-contrib-clean');
  85. grunt.loadNpmTasks('grunt-contrib-watch');
  86. //grunt.loadNpmTasks('grunt-jscs');
  87. //grunt.loadNpmTasks('grunt-karma');
  88. grunt.loadNpmTasks('grunt-tslint');
  89. //grunt.loadNpmTasks('grunt-typings');
  90. grunt.registerTask('default', ['tslint', 'browserify'/*, 'karma:ci'*/]);
  91. //grunt.registerTask('lint', ['tslint', 'jscs']);
  92. grunt.registerTask('test', ['browserify:debug'/*, 'karma:ci'*/]);
  93. //grunt.registerTask('test debug Firefox', ['browserify:debug', /*'karma:debugWithFirefox'*/]);
  94. //grunt.registerTask('test debug Chrome', ['browserify:debug', /*'karma:debugWithChrome'*/]);
  95. grunt.registerTask('rebuild', ['clean', 'default']);
  96. grunt.registerTask('publish', ['clean', 'browserify:dist']);
  97. grunt.registerTask('all', ['typings', 'default']);
  98. };