gruntfile.js 4.8 KB

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