summaryrefslogtreecommitdiffstats
path: root/build/generate-svg.js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2021-03-22 05:04:19 +0100
committerGitHub <noreply@github.com>2021-03-22 05:04:19 +0100
commit1a03fa7a4f353eb2f965cdcac39f630c281eca1e (patch)
tree042e54d01f25afff9f78c38cdc3d1c2da062118f /build/generate-svg.js
parenta587a284349e7c27d1bec39ef0dedb3972ef68c5 (diff)
downloadgitea-1a03fa7a4f353eb2f965cdcac39f630c281eca1e.tar.gz
gitea-1a03fa7a4f353eb2f965cdcac39f630c281eca1e.zip
Update JS dependencies (#15033)
* Update JS dependencies - Update all JS dependencies - For octicons, rename trashcan to trash - For svgo, migrate to v2 api, output seems to have slightly changed but icons look the same - For stylelint, update config, fix custom property duplicates - For monaco, drop legacy Edge support - For eslint, enable new rules, fix new issues - For less-loader, remove deprecated import syntax * update svgo usage in generate-images and rebuild logo.svg with it
Diffstat (limited to 'build/generate-svg.js')
-rwxr-xr-xbuild/generate-svg.js31
1 files changed, 10 insertions, 21 deletions
diff --git a/build/generate-svg.js b/build/generate-svg.js
index 09e08e48dc..97053a2958 100755
--- a/build/generate-svg.js
+++ b/build/generate-svg.js
@@ -2,7 +2,7 @@
'use strict';
const fastGlob = require('fast-glob');
-const Svgo = require('svgo');
+const {optimize, extendDefaultPlugins} = require('svgo');
const {resolve, parse} = require('path');
const {readFile, writeFile, mkdir} = require('fs').promises;
@@ -25,31 +25,20 @@ async function processFile(file, {prefix, fullName} = {}) {
if (prefix === 'octicon') name = name.replace(/-[0-9]+$/, ''); // chop of '-16' on octicons
}
- const svgo = new Svgo({
- plugins: [
- {removeXMLNS: true},
- {removeDimensions: true},
+ const {data} = optimize(await readFile(file, 'utf8'), {
+ plugins: extendDefaultPlugins([
+ 'removeXMLNS',
+ 'removeDimensions',
{
- addClassesToSVGElement: {
- classNames: [
- 'svg',
- name,
- ],
- },
+ name: 'addClassesToSVGElement',
+ params: {classNames: ['svg', name]},
},
{
- addAttributesToSVGElement: {
- attributes: [
- {'width': '16'},
- {'height': '16'},
- {'aria-hidden': 'true'},
- ],
- },
+ name: 'addAttributesToSVGElement',
+ params: {attributes: [{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}]},
},
- ],
+ ]),
});
-
- const {data} = await svgo.optimize(await readFile(file, 'utf8'));
await writeFile(resolve(outputDir, `${name}.svg`), data);
}