Gruntfile.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. 'bower_components/reveal.js/css'
  33. ]
  34. },
  35. files: {
  36. '<%= dirs.cssDest %>/<%= pkg.name %>.css': '<%= dirs.css %>/<%= pkg.name %>.scss',
  37. '<%= dirs.cssDest %>/<%= pkg.name %>-reveal.css': '<%= dirs.css %>/<%= pkg.name %>-reveal.scss'
  38. }
  39. },
  40. default: {
  41. options: {
  42. outputStyle: 'compressed',
  43. includePaths: [
  44. 'bower_components/bootstrap-sass-official/assets/stylesheets',
  45. 'bower_components/fontawesome/scss',
  46. 'bower_components/reveal.js/css'
  47. ]
  48. },
  49. files: {
  50. '<%= dirs.cssDest %>/<%= pkg.name %>.min.css': '<%= dirs.css %>/<%= pkg.name %>.scss',
  51. '<%= dirs.cssDest %>/<%= pkg.name %>-reveal.min.css': '<%= dirs.css %>/<%= pkg.name %>-reveal.scss'
  52. }
  53. }
  54. },
  55. concat: {
  56. dist: {
  57. files: {
  58. '<%= dirs.jsDest %>/<%= pkg.name %>.js': [
  59. 'bower_components/jquery/dist/jquery.js',
  60. 'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js',
  61. 'node_modules/socket.io-client/dist/socket.io.js',
  62. 'bower_components/marked/lib/marked.js',
  63. 'bower_components/jquery.cookie/jquery.cookie.js',
  64. 'resource/js/crowi.js'
  65. ],
  66. '<%= dirs.jsDest %>/<%= pkg.name %>-reveal.js': [
  67. 'bower_components/jquery/dist/jquery.js',
  68. 'bower_components/reveal.js/lib/js/head.min.js',
  69. 'bower_components/reveal.js/lib/js/html5shiv.js',
  70. 'bower_components/reveal.js/js/reveal.js'
  71. ],
  72. }
  73. },
  74. },
  75. uglify: {
  76. build: {
  77. files: {
  78. '<%= dirs.jsDest %>/<%= pkg.name %>.min.js': '<%= dirs.jsDest %>/<%= pkg.name %>.js',
  79. '<%= dirs.jsDest %>/<%= pkg.name %>-reveal.min.js': '<%= dirs.jsDest %>/<%= pkg.name %>-reveal.js'
  80. }
  81. }
  82. },
  83. jshint: {
  84. options: {
  85. jshintrc: true
  86. },
  87. all: paths.scripts
  88. },
  89. watch: {
  90. css: {
  91. files: paths.styles,
  92. tasks: ['sass'],
  93. },
  94. dev: {
  95. files: paths.all,
  96. tasks: ['dev'],
  97. },
  98. default: {
  99. files: paths.all,
  100. tasks: ['default'],
  101. },
  102. },
  103. });
  104. grunt.loadNpmTasks('grunt-contrib-uglify');
  105. grunt.loadNpmTasks('grunt-contrib-watch');
  106. grunt.loadNpmTasks('grunt-contrib-concat');
  107. grunt.loadNpmTasks('grunt-contrib-jshint');
  108. grunt.loadNpmTasks('grunt-sass');
  109. // grunt watch dev
  110. grunt.registerTask('default', ['sass', 'concat', 'uglify']);
  111. grunt.registerTask('dev', ['jshint', 'sass:dev', 'concat']);
  112. };