gruntfile.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*jshint esversion: 6 */
  2. module.exports = function(grunt) {
  3. grunt.initConfig({
  4. pkg: grunt.file.readJSON('package.json'),
  5. copy: {
  6. js: {
  7. expand: true,
  8. cwd: './node_modules',
  9. dest: './js/',
  10. flatten: true,
  11. filter: 'isFile',
  12. timestamp: true,
  13. src: [
  14. './bootstrap/dist/js/bootstrap.min.js',
  15. './corejs-typeahead/dist/typeahead.bundle.min.js',
  16. './jquery/dist/jquery.min.js',
  17. './leaflet/dist/leaflet.js',
  18. ]
  19. },
  20. css: {
  21. expand: true,
  22. cwd: './node_modules',
  23. dest: './css/',
  24. flatten: true,
  25. filter: 'isFile',
  26. timestamp: true,
  27. src: [
  28. './bootstrap/dist/css/bootstrap-theme.css',
  29. './bootstrap/dist/css/bootstrap-theme.min.css',
  30. './bootstrap/dist/css/bootstrap-theme.min.css.map',
  31. './leaflet/dist/leaflet.css',
  32. ]
  33. },
  34. fonts: {
  35. expand: true,
  36. cwd: './node_modules',
  37. dest: './fonts/',
  38. flatten: true,
  39. filter: 'isFile',
  40. timestamp: true,
  41. src: [
  42. './bootstrap/dist/fonts/glyphicons-*.*',
  43. ]
  44. },
  45. leaflet_images: {
  46. expand: true,
  47. cwd: './node_modules',
  48. dest: './css/images/',
  49. flatten: true,
  50. filter: 'isFile',
  51. timestamp: true,
  52. src: [
  53. './leaflet/dist/images/*.png',
  54. ]
  55. }
  56. },
  57. concat: {
  58. options: {
  59. separator: ';'
  60. },
  61. dist: {
  62. src: ['src/js/*.js', '../__common__/js/image_layout.js'],
  63. dest: 'js/searx.js'
  64. }
  65. },
  66. uglify: {
  67. options: {
  68. sourceMap: true,
  69. },
  70. dist: {
  71. files: {
  72. 'js/searx.min.js': ['<%= concat.dist.dest %>']
  73. }
  74. }
  75. },
  76. jshint: {
  77. files: ['gruntfile.js', 'js/searx_src/*.js', '../__common__/js/image_layout.js'],
  78. options: {
  79. reporterOutput: "",
  80. // options here to override JSHint defaults
  81. globals: {
  82. jQuery: true,
  83. console: true,
  84. module: true,
  85. document: true
  86. }
  87. }
  88. },
  89. less: {
  90. development: {
  91. options: {
  92. paths: ["src/less/pointhi", "src/less/logicodev", "src/less/logicodev-dark", "src/less/bootstrap"]
  93. },
  94. files: {
  95. "css/bootstrap.css": "src/less/bootstrap/bootstrap.less",
  96. "css/pointhi.css": "src/less/pointhi/oscar.less",
  97. "css/logicodev.css": "src/less/logicodev/oscar.less",
  98. "css/logicodev-dark.css": "src/less/logicodev-dark/oscar.less"
  99. }
  100. },
  101. production: {
  102. options: {
  103. paths: ["src/less/pointhi", "src/less/logicodev", "src/less/logicodev-dark", "src/less/bootstrap"],
  104. plugins: [
  105. new (require('less-plugin-clean-css'))()
  106. ],
  107. sourceMap: true,
  108. sourceMapURL: (name) => { const s = name.split('/'); return s[s.length - 1] + '.map';},
  109. outputSourceFiles: false,
  110. sourceMapRootpath: '../'
  111. },
  112. files: {
  113. "css/bootstrap.min.css": "css/bootstrap.css",
  114. "css/leaflet.min.css": "css/leaflet.css",
  115. "css/pointhi.min.css": "src/less/pointhi/oscar.less",
  116. "css/logicodev.min.css": "src/less/logicodev/oscar.less",
  117. "css/logicodev-dark.min.css": "src/less/logicodev-dark/oscar.less"
  118. }
  119. },
  120. },
  121. watch: {
  122. scripts: {
  123. files: ['<%= jshint.files %>'],
  124. tasks: ['jshint', 'concat', 'uglify']
  125. },
  126. oscar_styles: {
  127. files: ['src/less/pointhi/**/*.less'],
  128. tasks: ['less:development', 'less:production']
  129. },
  130. bootstrap_styles: {
  131. files: ['less/bootstrap/**/*.less'],
  132. tasks: ['less:bootstrap']
  133. }
  134. }
  135. });
  136. grunt.loadNpmTasks('grunt-contrib-copy');
  137. grunt.loadNpmTasks('grunt-contrib-uglify');
  138. grunt.loadNpmTasks('grunt-contrib-jshint');
  139. grunt.loadNpmTasks('grunt-contrib-watch');
  140. grunt.loadNpmTasks('grunt-contrib-concat');
  141. grunt.loadNpmTasks('grunt-contrib-less');
  142. grunt.registerTask('test', ['jshint']);
  143. grunt.registerTask('default', ['copy', 'jshint', 'concat', 'uglify', 'less']);
  144. grunt.registerTask('styles', ['less']);
  145. };