gruntfile.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. module.exports = function(grunt) {
  2. const path = require('path');
  3. grunt.initConfig({
  4. pkg: grunt.file.readJSON('package.json'),
  5. watch: {
  6. scripts: {
  7. files: ['<%= jshint.files %>', 'less/*.less'],
  8. tasks: ['jshint', 'concat', 'uglify', 'webfont', 'less:development', 'less:production']
  9. }
  10. },
  11. jshint: {
  12. files: ['js/searx_src/*.js', 'js/searx_header/*.js', '../__common__/js/*.js'],
  13. options: {
  14. reporterOutput: "",
  15. proto: true,
  16. // options here to override JSHint defaults
  17. globals: {
  18. browser: true,
  19. jQuery: false,
  20. devel: true
  21. }
  22. }
  23. },
  24. concat: {
  25. head_and_body: {
  26. options: {
  27. separator: ';'
  28. },
  29. files: {
  30. 'js/searx.head.js': ['js/searx_head/*.js'],
  31. 'js/searx.js': ['js/searx_src/*.js', '../__common__/js/*.js']
  32. }
  33. }
  34. },
  35. uglify: {
  36. options: {
  37. banner: '/*! simple/searx.min.js | <%= grunt.template.today("dd-mm-yyyy") %> | <%= process.env.GIT_URL %> */\n',
  38. output: {
  39. comments: 'some'
  40. },
  41. ie8: false,
  42. warnings: true,
  43. compress: false,
  44. mangle: true,
  45. sourceMap: true
  46. },
  47. dist: {
  48. files: {
  49. 'js/searx.head.min.js': ['js/searx.head.js'],
  50. 'js/searx.min.js': ['js/searx.js']
  51. }
  52. }
  53. },
  54. less: {
  55. development: {
  56. options: {
  57. paths: ["less"],
  58. banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | <%= process.env.GIT_URL %> */\n'
  59. },
  60. files: {
  61. "css/searx.css": "less/style.less",
  62. "css/searx-rtl.css": "less/style-rtl.less"
  63. }
  64. },
  65. production: {
  66. options: {
  67. paths: ["less"],
  68. plugins: [
  69. new (require('less-plugin-clean-css'))({
  70. advanced: true,
  71. compatibility: '*'
  72. })
  73. ],
  74. banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | <%= process.env.GIT_URL %> */\n'
  75. },
  76. files: {
  77. "css/searx.min.css": "less/style.less",
  78. "css/searx-rtl.min.css": "less/style-rtl.less"
  79. }
  80. },
  81. },
  82. webfont: {
  83. icons: {
  84. // src: 'node_modules/ionicons-npm/src/*.svg',
  85. src: [
  86. 'node_modules/ionicons-npm/src/navicon-round.svg',
  87. 'node_modules/ionicons-npm/src/search.svg',
  88. 'node_modules/ionicons-npm/src/play.svg',
  89. 'node_modules/ionicons-npm/src/link.svg',
  90. 'node_modules/ionicons-npm/src/chevron-up.svg',
  91. 'node_modules/ionicons-npm/src/chevron-left.svg',
  92. 'node_modules/ionicons-npm/src/chevron-right.svg',
  93. 'node_modules/ionicons-npm/src/arrow-down-a.svg',
  94. 'node_modules/ionicons-npm/src/arrow-up-a.svg',
  95. 'node_modules/ionicons-npm/src/arrow-swap.svg',
  96. 'node_modules/ionicons-npm/src/telephone.svg',
  97. 'node_modules/ionicons-npm/src/android-arrow-dropdown.svg',
  98. 'node_modules/ionicons-npm/src/android-globe.svg',
  99. 'node_modules/ionicons-npm/src/android-time.svg',
  100. 'node_modules/ionicons-npm/src/location.svg',
  101. 'node_modules/ionicons-npm/src/alert-circled.svg',
  102. 'node_modules/ionicons-npm/src/android-alert.svg',
  103. 'node_modules/ionicons-npm/src/ios-film-outline.svg',
  104. 'node_modules/ionicons-npm/src/music-note.svg',
  105. 'node_modules/ionicons-npm/src/ion-close-round.svg',
  106. 'node_modules/ionicons-npm/src/android-more-vertical.svg',
  107. 'magnet.svg',
  108. 'node_modules/ionicons-npm/src/android-close.svg',
  109. ],
  110. dest: 'fonts',
  111. destLess: 'less',
  112. options: {
  113. font: 'ion',
  114. hashes : true,
  115. syntax: 'bem',
  116. styles : 'font,icon',
  117. types : 'eot,woff2,woff,ttf,svg',
  118. order : 'eot,woff2,woff,ttf,svg',
  119. stylesheets : ['css', 'less'],
  120. relativeFontPath : '../fonts/',
  121. autoHint : false,
  122. normalize : false,
  123. // ligatures : true,
  124. optimize : true,
  125. // fontHeight : 400,
  126. rename : function(name) {
  127. basename = path.basename(name);
  128. if (basename === 'android-alert.svg') {
  129. return 'error.svg';
  130. }
  131. if (basename === 'alert-circled.svg') {
  132. return 'warning.svg';
  133. }
  134. if (basename === 'ion-close-round.svg') {
  135. return 'close.svg';
  136. }
  137. return basename.replace(/(ios|md|android)-/i, '');
  138. },
  139. templateOptions: {
  140. baseClass: 'ion-icon',
  141. classPrefix: 'ion-'
  142. }
  143. }
  144. }
  145. }
  146. });
  147. grunt.loadNpmTasks('grunt-contrib-watch');
  148. grunt.loadNpmTasks('grunt-contrib-uglify');
  149. grunt.loadNpmTasks('grunt-contrib-jshint');
  150. grunt.loadNpmTasks('grunt-contrib-concat');
  151. grunt.loadNpmTasks('grunt-contrib-less');
  152. grunt.loadNpmTasks('grunt-contrib-cssmin');
  153. grunt.loadNpmTasks('grunt-webfont');
  154. grunt.registerTask('test', ['jshint']);
  155. grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'less:development', 'less:production']);
  156. };