gruntfile.js 4.8 KB

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