Gruntfile.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * @package Crowi
  3. */
  4. module.exports = function(grunt) {
  5. var paths = {
  6. scripts: ['Gruntfile.js', 'app.js', 'lib/**/*.js', 'resource/js/**/*.js'],
  7. tests: ['test/**/*.test.js'],
  8. styles: ['resource/css/*.scss'],
  9. all: []
  10. };
  11. Object.keys(paths).forEach(function(name) {
  12. paths[name].forEach(function(path) {
  13. paths.all[paths.all.length] = path;
  14. });
  15. });
  16. // Project configuration.
  17. grunt.initConfig({
  18. pkg: grunt.file.readJSON('package.json'),
  19. dirs: {
  20. js: 'resource/js',
  21. jsDest: 'public/js',
  22. css: 'resource/css',
  23. cssDest: 'public/css',
  24. web: 'public/'
  25. },
  26. sass: {
  27. dev: {
  28. options: {
  29. outputStyle: 'nested',
  30. includePaths: [
  31. 'bower_components/bootstrap-sass-official/assets/stylesheets',
  32. 'bower_components/fontawesome/scss',
  33. 'bower_components/reveal.js/css'
  34. ]
  35. },
  36. files: {
  37. '<%= dirs.cssDest %>/<%= pkg.name %>-main.css': '<%= dirs.css %>/<%= pkg.name %>.scss',
  38. '<%= dirs.cssDest %>/<%= pkg.name %>-reveal.css': '<%= dirs.css %>/<%= pkg.name %>-reveal.scss'
  39. }
  40. },
  41. default: {
  42. options: {
  43. outputStyle: 'compressed',
  44. includePaths: [
  45. 'bower_components/bootstrap-sass-official/assets/stylesheets',
  46. 'bower_components/fontawesome/scss',
  47. 'bower_components/reveal.js/css'
  48. ]
  49. },
  50. files: {
  51. '<%= dirs.cssDest %>/<%= pkg.name %>-main.min.css': '<%= dirs.css %>/<%= pkg.name %>.scss',
  52. '<%= dirs.cssDest %>/<%= pkg.name %>-reveal.min.css': '<%= dirs.css %>/<%= pkg.name %>-reveal.scss'
  53. }
  54. }
  55. },
  56. concat: {
  57. dist: {
  58. files: {
  59. '<%= dirs.cssDest %>/<%= pkg.name %>.css': [
  60. 'bower_components/highlightjs/styles/tomorrow-night.css',
  61. '<%= dirs.cssDest %>/<%= pkg.name %>-main.css',
  62. ],
  63. '<%= dirs.cssDest %>/<%= pkg.name %>.min.css': [
  64. 'bower_components/highlightjs/styles/tomorrow-night.css', // TODO minimize
  65. '<%= dirs.cssDest %>/<%= pkg.name %>-main.min.css',
  66. ],
  67. '<%= dirs.jsDest %>/<%= pkg.name %>.js': [
  68. 'bower_components/jquery/dist/jquery.js',
  69. 'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js',
  70. 'node_modules/socket.io-client/socket.io.js',
  71. 'bower_components/marked/lib/marked.js',
  72. 'bower_components/jquery.cookie/jquery.cookie.js',
  73. 'bower_components/highlightjs/highlight.pack.js',
  74. 'resource/js/crowi.js'
  75. ],
  76. '<%= dirs.jsDest %>/<%= pkg.name %>-reveal.js': [
  77. 'bower_components/jquery/dist/jquery.js',
  78. 'bower_components/reveal.js/lib/js/head.min.js',
  79. 'bower_components/reveal.js/lib/js/html5shiv.js',
  80. 'bower_components/reveal.js/js/reveal.js'
  81. ],
  82. }
  83. },
  84. },
  85. uglify: {
  86. build: {
  87. files: {
  88. '<%= dirs.jsDest %>/<%= pkg.name %>.min.js': '<%= dirs.jsDest %>/<%= pkg.name %>.js',
  89. '<%= dirs.jsDest %>/<%= pkg.name %>-reveal.min.js': '<%= dirs.jsDest %>/<%= pkg.name %>-reveal.js'
  90. }
  91. }
  92. },
  93. jshint: {
  94. options: {
  95. jshintrc: true
  96. },
  97. all: paths.scripts
  98. },
  99. mochaTest: {
  100. all: {
  101. src: ['test/**/*.test.js'],
  102. options: {
  103. globals: ['chai'],
  104. require: ['test/bootstrap.js'],
  105. timeout: 3000,
  106. quiet: false,
  107. clearRequireCache: true,
  108. },
  109. }
  110. },
  111. watch: {
  112. css: {
  113. files: paths.styles,
  114. tasks: ['sass'],
  115. },
  116. dev: {
  117. files: paths.all,
  118. tasks: ['dev'],
  119. },
  120. test: {
  121. files: paths.all,
  122. tasks: ['test'],
  123. },
  124. default: {
  125. files: paths.all,
  126. tasks: ['default'],
  127. },
  128. },
  129. });
  130. grunt.loadNpmTasks('grunt-contrib-uglify');
  131. grunt.loadNpmTasks('grunt-contrib-watch');
  132. grunt.loadNpmTasks('grunt-contrib-concat');
  133. grunt.loadNpmTasks('grunt-contrib-jshint');
  134. grunt.loadNpmTasks('grunt-sass');
  135. grunt.loadNpmTasks('grunt-mocha-test');
  136. // grunt watch dev
  137. grunt.registerTask('default', ['sass', 'concat', 'uglify']);
  138. grunt.registerTask('dev', ['sass:dev', 'concat', 'jshint']);
  139. grunt.registerTask('test', ['mochaTest']);
  140. };