Gruntfile.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * @package RMW
  3. */
  4. module.exports = function(grunt) {
  5. var paths = {
  6. scripts: ['Gruntfile.js', 'app.js', 'lib/**/*.js', 'models/**/*.js', 'routes/**/*.js', 'form/**/*.js', 'resource/js/**/*.js'],
  7. styles: ['resource/css/*.scss'],
  8. all: []
  9. };
  10. Object.keys(paths).forEach(function(name) {
  11. paths[name].forEach(function(path) {
  12. paths.all[paths.all.length] = path;
  13. });
  14. });
  15. // Project configuration.
  16. grunt.initConfig({
  17. pkg: grunt.file.readJSON('package.json'),
  18. dirs: {
  19. js: 'resource/js',
  20. jsDest: 'public/js',
  21. css: 'resource/css',
  22. cssDest: 'public/css',
  23. web: 'public/'
  24. },
  25. sass: {
  26. dev: {
  27. options: {
  28. outputStyle: 'nested',
  29. includePaths: [
  30. 'bower_components/bootstrap-sass-official/assets/stylesheets',
  31. 'bower_components/fontawesome/scss'
  32. ]
  33. },
  34. files: {
  35. '<%= dirs.cssDest %>/<%= pkg.name %>.css': '<%= dirs.css %>/<%= pkg.name %>.scss',
  36. '<%= dirs.cssDest %>/<%= pkg.name %>-reveal.css': '<%= dirs.css %>/<%= pkg.name %>-reveal.scss'
  37. }
  38. },
  39. default: {
  40. options: {
  41. outputStyle: 'compressed',
  42. includePaths: [
  43. 'bower_components/bootstrap-sass-official/assets/stylesheets',
  44. 'bower_components/fontawesome/scss'
  45. ]
  46. },
  47. files: {
  48. '<%= dirs.cssDest %>/<%= pkg.name %>.min.css': '<%= dirs.css %>/<%= pkg.name %>.scss',
  49. '<%= dirs.cssDest %>/<%= pkg.name %>-reveal.min.css': '<%= dirs.css %>/<%= pkg.name %>-reveal.scss'
  50. }
  51. }
  52. },
  53. concat: {
  54. dist: {
  55. src: [
  56. // Bootstrap
  57. 'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js',
  58. // socket.io
  59. 'node_modules/socket.io-client/dist/socket.io.js',
  60. // markd
  61. 'node_modules/marked/lib/marked.js',
  62. // jquery.cookie
  63. 'node_modules/jquery.cookie/jquery.cookie.js',
  64. // crowi
  65. 'resource/js/crowi.js'
  66. ],
  67. dest: '<%= dirs.jsDest %>/<%= pkg.name %>.js'
  68. }
  69. },
  70. uglify: {
  71. build: {
  72. src: '<%= concat.dist.dest %>',
  73. dest: '<%= dirs.jsDest %>/<%= pkg.name %>.min.js'
  74. }
  75. },
  76. jshint: {
  77. options: {
  78. jshintrc: true
  79. },
  80. all: ['Gruntfile.js', 'lib/**/*.js', 'models/**/*.js', 'routes/**/*.js', 'form/**/*.js', 'resource/js/**/*.js']
  81. },
  82. watch: {
  83. css: {
  84. files: paths.styles,
  85. tasks: ['sass'],
  86. },
  87. dev: {
  88. files: paths.all,
  89. tasks: ['dev'],
  90. },
  91. default: {
  92. files: paths.all,
  93. tasks: ['default'],
  94. },
  95. },
  96. });
  97. grunt.loadNpmTasks('grunt-contrib-uglify');
  98. grunt.loadNpmTasks('grunt-contrib-watch');
  99. grunt.loadNpmTasks('grunt-contrib-concat');
  100. grunt.loadNpmTasks('grunt-contrib-jshint');
  101. grunt.loadNpmTasks('grunt-sass');
  102. // grunt watch dev
  103. grunt.registerTask('default', ['sass', 'concat', 'uglify']);
  104. grunt.registerTask('dev', ['jshint', 'sass:dev', 'concat']);
  105. };