From 50d95d257c0e63414facd6b16a4f0e3644b1d9e8 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 29 Mar 2023 20:30:34 +0800 Subject: [PATCH] fix(cci/ccp/ct/ic): remove attrs. --- core/README.md | 2 +- icons/cci/.gitignore | 1 + icons/cci/svgo.config.js | 23 +++++++++++++++++++++++ icons/ccp/svgo.config.js | 3 --- icons/ct/svgo.config.js | 29 +++++++++++++++++++++++++++++ icons/ic/.gitignore | 1 + icons/ic/svgo.config.js | 31 +++++++++++++++++++++++++++++++ package.json | 2 +- 8 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 icons/cci/svgo.config.js create mode 100644 icons/ct/svgo.config.js create mode 100644 icons/ic/svgo.config.js diff --git a/core/README.md b/core/README.md index bf1b49b197..20fd03819c 100644 --- a/core/README.md +++ b/core/README.md @@ -151,7 +151,7 @@ Example: }, "devDependencies": { "icongo": "*", - "tsbb": "^4.0.2" + "tsbb": "^4.0.3" } } ``` diff --git a/icons/cci/.gitignore b/icons/cci/.gitignore index 942786ecaf..94f6d063ed 100644 --- a/icons/cci/.gitignore +++ b/icons/cci/.gitignore @@ -4,6 +4,7 @@ !.gitignore !.npmignore !tsconfig.json +!svgo.config.js !package.json !data !README.md \ No newline at end of file diff --git a/icons/cci/svgo.config.js b/icons/cci/svgo.config.js new file mode 100644 index 0000000000..435704ca3c --- /dev/null +++ b/icons/cci/svgo.config.js @@ -0,0 +1,23 @@ + +/** @type {import('svgo').Config} */ +module.exports = { + multipass: true, + js2svg: { + indent: 2, // string with spaces or number of spaces. 4 by default + pretty: true, // boolean, false by default + }, + plugins: [ + 'cleanupIds', + 'removeComments', + 'removeDimensions', + { + name: 'removeAttrs', + fn: (ast, params, info) => { + delete ast.children[0]?.attributes['id']; + delete ast.children[0]?.attributes['version']; + delete ast.children[0]?.attributes['style']; + delete ast.children[0]?.attributes['xml:space']; + }, + } + ] +} diff --git a/icons/ccp/svgo.config.js b/icons/ccp/svgo.config.js index ef07e8a7a2..5bddfa2e0d 100644 --- a/icons/ccp/svgo.config.js +++ b/icons/ccp/svgo.config.js @@ -7,9 +7,6 @@ module.exports = { pretty: true, // boolean, false by default }, plugins: [ - 'cleanupIds', - 'removeComments', - 'removeDimensions', { name: 'removeAttrs', fn: (ast, params, info) => { diff --git a/icons/ct/svgo.config.js b/icons/ct/svgo.config.js new file mode 100644 index 0000000000..58b9d2f493 --- /dev/null +++ b/icons/ct/svgo.config.js @@ -0,0 +1,29 @@ + +/** @type {import('svgo').Config} */ +module.exports = { + multipass: true, + js2svg: { + indent: 2, // string with spaces or number of spaces. 4 by default + pretty: true, // boolean, false by default + }, + plugins: [ + { + name: "removeAttrs", + params: { + attrs: "(stroke-linejoin)" + } + }, + { + name: 'removeAttrs', + fn: (ast, params, info) => { + delete ast.children[0]?.attributes['id']; + delete ast.children[0]?.attributes['y']; + delete ast.children[0]?.attributes['x']; + delete ast.children[0]?.attributes['version']; + delete ast.children[0]?.attributes['style']; + delete ast.children[0]?.attributes['xml:space']; + delete ast.children[0]?.attributes['xmlns:xlink']; + }, + } + ] +} diff --git a/icons/ic/.gitignore b/icons/ic/.gitignore index 4141944632..0000ea5e14 100644 --- a/icons/ic/.gitignore +++ b/icons/ic/.gitignore @@ -5,6 +5,7 @@ !.npmignore !tsconfig.json !package.json +!svgo.config.js !data !README.md !cpy.mjs \ No newline at end of file diff --git a/icons/ic/svgo.config.js b/icons/ic/svgo.config.js new file mode 100644 index 0000000000..56f0697741 --- /dev/null +++ b/icons/ic/svgo.config.js @@ -0,0 +1,31 @@ + +/** @type {import('svgo').Config} */ +module.exports = { + multipass: true, + js2svg: { + indent: 2, // string with spaces or number of spaces. 4 by default + pretty: true, // boolean, false by default + }, + plugins: [ + 'removeXMLNS', + 'convertColors', + { + name: "removeAttrs", + params: { + attrs: "(stroke-linejoin|block-progression)" + } + }, + { + name: 'removeAttrs', + fn: (ast, params, info) => { + delete ast.children[0]?.attributes['id']; + delete ast.children[0]?.attributes['y']; + delete ast.children[0]?.attributes['x']; + delete ast.children[0]?.attributes['version']; + delete ast.children[0]?.attributes['style']; + delete ast.children[0]?.attributes['xml:space']; + delete ast.children[0]?.attributes['xmlns:xlink']; + }, + } + ] +} diff --git a/package.json b/package.json index bbe5e106ec..38a4ff08de 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,6 @@ "lerna": "^6.0.0", "lint-staged": "^13.0.3", "prettier": "^2.7.1", - "tsbb": "^4.0.2" + "tsbb": "^4.0.3" } }