Gruntfile.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. module.exports = function(grunt) {
  2. // These are the files used in order to build the Jcrop.js source
  3. // variable is used in initConfig concat rule below
  4. // also used for the watch task
  5. var jcrop_sources = [
  6. 'src/intro.js',
  7. 'src/constructor.js',
  8. 'src/static.js',
  9. 'src/stage/Abstract.js',
  10. 'src/stage/Image.js',
  11. //'src/stage/CssTransform.js',
  12. 'src/stage/Canvas.js',
  13. 'src/filter/BackoffFilter.js',
  14. 'src/filter/ConstrainFilter.js',
  15. 'src/filter/ExtentFilter.js',
  16. 'src/filter/GridFilter.js',
  17. 'src/filter/RatioFilter.js',
  18. 'src/filter/RoundFilter.js',
  19. 'src/filter/ShadeFilter.js',
  20. 'src/component/CanvasAnimator.js',
  21. 'src/component/CropAnimator.js',
  22. 'src/component/DragState.js',
  23. 'src/component/EventManager.js',
  24. 'src/component/ImageLoader.js',
  25. 'src/component/JcropTouch.js',
  26. 'src/component/KeyWatcher.js',
  27. 'src/component/Selection.js',
  28. 'src/component/StageDrag.js',
  29. 'src/component/StageManager.js',
  30. 'src/component/Thumbnailer.js',
  31. 'src/component/DialDrag.js',
  32. 'src/defaults.js',
  33. 'src/api.js',
  34. 'src/plugin.js',
  35. 'src/modernizr.js',
  36. 'src/outro.js'
  37. ];
  38. var json = grunt.file.readJSON('package.json');
  39. // Project configuration
  40. grunt.initConfig({
  41. pkg: json,
  42. watch: {
  43. css: {
  44. files: [ 'src/**/*.less' ],
  45. tasks: [ 'css' ]
  46. },
  47. js: {
  48. files: [ 'src/**/*.js' ],
  49. tasks: [ 'js' ]
  50. }
  51. },
  52. concat: {
  53. options: {
  54. banner: '/*! <%= pkg.name %>.js v<%= pkg.version %> - build: <%= grunt.template.today("yyyymmdd") %>\n'+
  55. ' * @copyright 2008-2015 Tapmodo Interactive LLC\n' +
  56. ' * @license Free software under MIT License\n'+
  57. ' * @website http://jcrop.org/\n'+
  58. ' **/\n'
  59. },
  60. dist: {
  61. src: jcrop_sources,
  62. dest: 'js/<%= pkg.name %>.js'
  63. }
  64. },
  65. less: {
  66. dist: {
  67. files: {
  68. "css/Jcrop.css": "src/css/Jcrop.less"
  69. }
  70. }
  71. },
  72. cssmin: {
  73. dist: {
  74. options: {
  75. keepSpecialComments: 0,
  76. banner: '/*! <%= pkg.name %>.min.css v<%= pkg.version %> - build: <%= grunt.template.today("yyyymmdd") %>\n'+
  77. ' * Copyright 2008-2015 Tapmodo Interactive LLC\n' +
  78. ' * Free software under MIT License\n'+
  79. ' **/\n'
  80. },
  81. files: {
  82. "css/Jcrop.min.css": "css/Jcrop.css"
  83. }
  84. }
  85. },
  86. usebanner: {
  87. dist: {
  88. options: {
  89. banner: '/*! <%= pkg.name %>.css v<%= pkg.version %> - build: <%= grunt.template.today("yyyymmdd") %>\n'+
  90. ' * Copyright 2008-2015 Tapmodo Interactive LLC\n' +
  91. ' * Free software under MIT License\n'+
  92. ' **/\n'
  93. },
  94. files: {
  95. src: [ 'css/Jcrop.css' ]
  96. }
  97. }
  98. },
  99. uglify: {
  100. options: {
  101. banner: '/*! <%= pkg.name %>.min.js v<%= pkg.version %> - build: <%= grunt.template.today("yyyymmdd") %>\n' +
  102. ' * Copyright 2008-2015 Tapmodo Interactive LLC\n' +
  103. ' * Free software under MIT License\n'+
  104. ' **/\n'
  105. },
  106. dist: {
  107. src: 'js/<%= pkg.name %>.js',
  108. dest: 'js/<%= pkg.name %>.min.js'
  109. }
  110. }
  111. });
  112. // Load grunt plugins
  113. grunt.loadNpmTasks('grunt-contrib-concat');
  114. grunt.loadNpmTasks('grunt-contrib-uglify');
  115. grunt.loadNpmTasks('grunt-contrib-less');
  116. grunt.loadNpmTasks('grunt-contrib-cssmin');
  117. grunt.loadNpmTasks('grunt-contrib-watch');
  118. grunt.loadNpmTasks('grunt-banner');
  119. // Default tasks
  120. grunt.registerTask('default', ['js','css']);
  121. grunt.registerTask('js', ['concat','uglify']);
  122. grunt.registerTask('css', ['less','cssmin','usebanner']);
  123. };