diff --git a/searx/static/themes/simple/gruntfile.js b/searx/static/themes/simple/gruntfile.js
index 630cac212..e3dc5f865 100644
--- a/searx/static/themes/simple/gruntfile.js
+++ b/searx/static/themes/simple/gruntfile.js
@@ -3,6 +3,7 @@
module.exports = function (grunt) {
const eachAsync = require('each-async');
+ const svgo = require('svgo');
function file_exists (filepath) {
// filter function to exit grunt task with error if a (src) file not exists
@@ -27,7 +28,7 @@ module.exports = function (grunt) {
'copy',
'uglify',
'less',
- 'image',
+ 'optimizesvg',
'svg2png',
'svg2jinja'
]
@@ -139,10 +140,19 @@ module.exports = function (grunt) {
],
},
},
- image: {
+ optimizesvg: {
svg4web: {
- options: {
- svgo: ['--config', 'svg4web.svgo.js']
+ config: {
+ plugins: [
+ {
+ name: 'preset-default',
+ },
+ // make diff friendly
+ 'sortAttrs',
+ // Optimize SVG for WEB usage
+ 'convertStyleToAttrs',
+ 'removeXMLNS'
+ ],
},
files: {
'<%= _templates %>/simple/searxng-wordmark.min.svg': '<%= _brand %>/searxng-wordmark.svg',
@@ -151,8 +161,14 @@ module.exports = function (grunt) {
}
},
favicon: {
- options: {
- svgo: ['--config', 'svg4favicon.svgo.js']
+ config: {
+ plugins: [
+ {
+ name: 'preset-default',
+ },
+ // make diff friendly
+ 'sortAttrs',
+ ],
},
files: {
'img/favicon.svg': '<%= _brand %>/searxng-wordmark.svg'
@@ -197,8 +213,21 @@ module.exports = function (grunt) {
},
});
+ grunt.registerMultiTask('optimizesvg', 'Optimize SVG', function () {
+ for (const file of this.files) {
+ try {
+ const svgContent = grunt.file.read(file.src[0], { encoding: 'utf8' });
+ const optimizedSvgContent = svgo.optimize(svgContent, this.config);
+ grunt.file.write(file.dest, optimizedSvgContent.data, { encoding: 'utf8' });
+ grunt.log.ok(file.dest + ' created (' + optimizedSvgContent.data.length + ' bytes)');
+ } catch (err) {
+ grunt.log.error(err);
+ }
+ }
+ })
+
grunt.registerMultiTask('svg2jinja', 'Create Jinja2 macro', function () {
- const ejs = require('ejs'), svgo = require('svgo');
+ const ejs = require('ejs');
const icons = {}
for (const iconName in this.data.src) {
const svgFileName = this.data.src[iconName];
@@ -286,7 +315,6 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-image');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-stylelint');
@@ -300,7 +328,7 @@ module.exports = function (grunt) {
'copy',
'uglify',
'less',
- 'image',
+ 'optimizesvg',
'svg2png',
'svg2jinja',
]);
diff --git a/searx/static/themes/simple/img/img_load_error.svg b/searx/static/themes/simple/img/img_load_error.svg
index 27ff0f056..8cc35b75f 100644
--- a/searx/static/themes/simple/img/img_load_error.svg
+++ b/searx/static/themes/simple/img/img_load_error.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/searx/static/themes/simple/img/searxng.svg b/searx/static/themes/simple/img/searxng.svg
index e965ed242..77d217399 100644
--- a/searx/static/themes/simple/img/searxng.svg
+++ b/searx/static/themes/simple/img/searxng.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/searx/static/themes/simple/package.json b/searx/static/themes/simple/package.json
index 871b7a60d..2fad662ff 100644
--- a/searx/static/themes/simple/package.json
+++ b/searx/static/themes/simple/package.json
@@ -18,7 +18,8 @@
"stylelint": "^13.13.1",
"stylelint-config-standard": "^22.0.0",
"ejs": "^3.1.8",
- "svgo": "^3.0.0"
+ "svgo": "^3.0.0",
+ "each-async": "2.0.0"
},
"dependencies": {
"autocomplete-js": "2.7.1",
diff --git a/searx/static/themes/simple/svg4favicon.svgo.js b/searx/static/themes/simple/svg4favicon.svgo.js
deleted file mode 100644
index b9dd0da8e..000000000
--- a/searx/static/themes/simple/svg4favicon.svgo.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * @license
- * SPDX-License-Identifier: AGPL-3.0-or-later
- *
- * svgo config: Optimize SVG for WEB usage
- */
-
-module.exports = {
- plugins: [
- {
- name: 'preset-default',
- },
- // make diff friendly
- 'sortAttrs',
- ],
-};
diff --git a/searx/static/themes/simple/svg4web.svgo.js b/searx/static/themes/simple/svg4web.svgo.js
deleted file mode 100644
index 83f74cde1..000000000
--- a/searx/static/themes/simple/svg4web.svgo.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * @license
- * SPDX-License-Identifier: AGPL-3.0-or-later
- *
- * svgo config: Optimize SVG for WEB usage
- */
-
-module.exports = {
- plugins: [
- {
- name: 'preset-default',
- },
- // make diff friendly
- 'sortAttrs',
- // Optimize SVG for WEB usage
- 'convertStyleToAttrs',
- 'removeXMLNS'
- ],
-};
diff --git a/searx/templates/simple/searxng-wordmark.min.svg b/searx/templates/simple/searxng-wordmark.min.svg
index 45cc2c05b..262414509 100644
--- a/searx/templates/simple/searxng-wordmark.min.svg
+++ b/searx/templates/simple/searxng-wordmark.min.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file