Skip to content
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d14cd6
chore: update deps version
liweijie0812 Sep 15, 2025
29033d4
feat: upgrade svgo to v4
liweijie0812 Sep 16, 2025
4e8b767
chore: upgrade husky to v9
liweijie0812 Sep 17, 2025
aa5846d
chore: upgrade fs-extra to v11
liweijie0812 Sep 17, 2025
d938cc3
chore: upgrade cross-env to v11
liweijie0812 Sep 17, 2025
1fd31de
chore: upgrade cross-env to v11
liweijie0812 Sep 17, 2025
d2b4325
chore: upgrade lint-staged to v16
liweijie0812 Sep 17, 2025
6f062a9
chore: upgrade del to v8
liweijie0812 Sep 17, 2025
fe29c13
chore: upgrade del to v8
liweijie0812 Sep 17, 2025
8aef4c1
chore: fix
liweijie0812 Sep 17, 2025
1d9cc3d
chore: upgrade gulp-rename
liweijie0812 Sep 17, 2025
5385e42
chore: upgrade ts-node to v10
liweijie0812 Sep 17, 2025
adc270d
chore: upgrade camelcase to v10, remove uppercamelcase
liweijie0812 Sep 17, 2025
0e7a825
chore: remove merge2 merge-stream
liweijie0812 Sep 17, 2025
da20ab6
chore: upgrade rimraf to v6
liweijie0812 Sep 17, 2025
f56985c
chore: upgrade decamelize to v6
liweijie0812 Sep 17, 2025
e6c8a1d
chore: upgrade gulp to v5
liweijie0812 Sep 17, 2025
892d478
chore: update pnpm-workspace.yaml
liweijie0812 Sep 17, 2025
b25288a
chore: fix lock
liweijie0812 Sep 17, 2025
8114dbe
chore: update deps
liweijie0812 Sep 17, 2025
bb5c9d5
chore: upgrade gulp-iconfont to v11
liweijie0812 Sep 17, 2025
6e031d1
chore: remove .npmrc
liweijie0812 Sep 17, 2025
8116002
chore: fix ts warning
liweijie0812 Sep 18, 2025
69120af
chore: rollup-plugin-terser is Deprecated, use @rollup/plugin-terser
liweijie0812 Sep 18, 2025
e642a80
chore: fix build
liweijie0812 Sep 18, 2025
94159b9
chore: pin gulp-iconfont 11.0.1
liweijie0812 Sep 22, 2025
d736cdb
Merge branch 'develop' into chore/deps
liweijie0812 Nov 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

husky 9以后不需要

. "$(dirname "$0")/_/husky.sh"

pnpm lint-staged
4 changes: 2 additions & 2 deletions gulp/clean-dir.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import del from 'del';
import { deleteAsync } from 'del';

export const clearDir = (paths: string[]) => () => del(paths);
export const clearDir = (paths: string[]) => () => deleteAsync(paths);
138 changes: 65 additions & 73 deletions gulp/svgo.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,79 @@
import SVGO from 'svgo';
import type { PluginConfig, Config } from 'svgo';
import { optimize } from 'svgo';
import { createTransformStreamAsync } from './transform';

export interface SVGOConfig {
removeXMLNS?: boolean;
cleanupAttrs?: boolean ;
removeDoctype?: boolean ;
removeXMLProcInst?: boolean ;
removeComments?: boolean ;
removeMetadata?: boolean ;
removeTitle?: boolean ;
removeDesc?: boolean ;
removeUselessDefs?: boolean ;
removeEditorsNSData?: boolean ;
removeEmptyAttrs?: boolean ;
removeHiddenElems?: boolean ;
removeEmptyText?: boolean ;
removeEmptyContainers?: boolean ;
removeViewBox?: boolean ;
cleanupEnableBackground?: boolean ;
convertStyleToAttrs?: boolean ;
convertPathData?: boolean ;
convertTransform?: boolean ;
removeUnknownsAndDefaults?: boolean ;
removeNonInheritableGroupAttrs?: boolean ;
removeUselessStrokeAndFill?: boolean ;
removeUnusedNS?: boolean ;
cleanupIDs?: boolean ;
cleanupNumericValues?: boolean ;
moveElemsAttrsToGroup?: boolean ;
moveGroupAttrsToElems?: boolean ;
collapseGroups?: boolean ;
removeRasterImages?: boolean ;
mergePaths?: boolean ;
convertShapeToPath?: boolean ;
sortAttrs?: boolean ;
removeDimensions?: boolean ;
removeXMLNS?: boolean;
cleanupAttrs?: boolean;
removeDoctype?: boolean;
removeXMLProcInst?: boolean;
removeComments?: boolean;
removeMetadata?: boolean;
removeTitle?: boolean;
removeDesc?: boolean;
removeUselessDefs?: boolean;
removeEditorsNSData?: boolean;
removeEmptyAttrs?: boolean;
removeHiddenElems?: boolean;
removeEmptyText?: boolean;
removeEmptyContainers?: boolean;
removeViewBox?: boolean;
cleanupEnableBackground?: boolean;
convertStyleToAttrs?: boolean;
convertPathData?: boolean;
convertTransform?: boolean;
removeUnknownsAndDefaults?: boolean;
removeNonInheritableGroupAttrs?: boolean;
removeUselessStrokeAndFill?: boolean;
removeUnusedNS?: boolean;
cleanupIDs?: boolean;
cleanupNumericValues?: boolean;
moveElemsAttrsToGroup?: boolean;
moveGroupAttrsToElems?: boolean;
collapseGroups?: boolean;
removeRasterImages?: boolean;
mergePaths?: boolean;
convertShapeToPath?: boolean;
sortAttrs?: boolean;
removeDimensions?: boolean;
}

function getSVGOOption(config: SVGOConfig = {}) {
function getSVGOOption(config: SVGOConfig = {}): Config {
const { removeXMLNS = true } = config;
const plugins: PluginConfig[] = [
{
// https://svgo.dev/docs/preset-default/
name: 'preset-default',
params: {
overrides: {
cleanupAttrs: false,
convertPathData: false,
removeUselessStrokeAndFill: false,
cleanupIds: false,
cleanupNumericValues: false,
moveElemsAttrsToGroup: false,
mergePaths: false,
},
},
},
'convertStyleToAttrs',
'removeRasterImages',
'removeDimensions',
{ name: 'removeAttrs', params: { attrs: ['class'] } },
];
if (removeXMLNS) {
plugins.push('removeXMLNS');
}

return {
floatPrecision: 2,
plugins: [
{ cleanupAttrs: false },
{ removeDoctype: true },
{ removeXMLProcInst: true },
{ removeXMLNS },
{ removeComments: true },
{ removeMetadata: true },
{ removeTitle: true },
{ removeDesc: true },
{ removeUselessDefs: true },
{ removeEditorsNSData: true },
{ removeEmptyAttrs: true },
{ removeHiddenElems: true },
{ removeEmptyText: true },
{ removeEmptyContainers: true },
{ removeViewBox: false },
{ cleanupEnableBackground: true },
{ convertStyleToAttrs: true },
{ convertPathData: false },
{ convertTransform: true },
{ removeUnknownsAndDefaults: true },
{ removeNonInheritableGroupAttrs: true },
{ removeUselessStrokeAndFill: false },
{ removeUnusedNS: true },
{ cleanupIDs: false }, // remain id to identify different paths
{ cleanupNumericValues: false }, // avoid path destroyed
{ moveElemsAttrsToGroup: false }, // remain each path attrs
{ moveGroupAttrsToElems: true },
{ collapseGroups: true },
{ removeRasterImages: false },
{ mergePaths: false },
{ convertShapeToPath: true },
{ sortAttrs: true },
{ removeDimensions: true },
{ removeAttrs: { attrs: ['class'] } },
],
plugins,
};
}

export const svgo = (config?: SVGOConfig) => {
const optimizer = new SVGO(getSVGOOption(config));
return createTransformStreamAsync(async (raw: string) => (await optimizer.optimize(raw)).data);
const options = getSVGOOption(config);
return createTransformStreamAsync(
async (raw: string) => optimize(raw, options).data,
);
};
3 changes: 1 addition & 2 deletions gulp/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import camelCase from 'camelcase';
export { renderNode } from './render';

export function upperCamelCase(name: string) {
const cased = camelCase.apply(camelCase, [name]);
return cased.charAt(0).toUpperCase() + cased.slice(1);
return camelCase(name, { pascalCase: true });
}

export function allSubDirsForLevel(rootPath: string, relativeLevel: number): string[] {
Expand Down
6 changes: 4 additions & 2 deletions gulpfile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { TaskFunction } from 'undertaker';
import { parallel, series } from 'gulp';

import { reactTask } from './packages/react/gulp';
Expand All @@ -13,8 +14,7 @@ import { iconViewTask } from './packages/view/gulp';
import { wcTask } from './packages/web-components/gulp';

const source: string[] = ['svg/*.svg'];

export default series(
const defaultTask: TaskFunction = series(
parallel(
reactTask(source),
vueTask(source),
Expand All @@ -27,3 +27,5 @@ export default series(
wcTask(source),
),
);

export default defaultTask;
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
},
"scripts": {
"preinstall": "npx -y only-allow pnpm",
"husky": "husky",
"prepare": "husky install",
"prepare": "husky",
"dev:icons": "pnpm -C packages/view dev ",
"lint": "eslint ./packages --max-warnings 0 --ext .ts,.tsx --fix",
"generate": "cross-env gulp --require ts-node/register/transpile-only"
"generate": "cross-env gulp --preload ts-node/register/transpile-only"
},
"devDependencies": {
"@changesets/cli": "catalog:",
Expand All @@ -35,11 +34,10 @@
"@types/gulp-rename": "catalog:types",
"@types/gulp-sourcemaps": "catalog:types",
"@types/gulp-svg-sprite": "catalog:types",
"@types/merge-stream": "catalog:types",
"@types/merge2": "catalog:types",
"@types/svg-parser": "catalog:types",
"@types/svgo": "catalog:types",
"@types/through2": "catalog:types",
"@types/undertaker": "catalog:types",
"@types/xmldom": "catalog:types",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"camelcase": "catalog:",
Expand All @@ -63,8 +61,6 @@
"gulp-typescript": "catalog:",
"husky": "catalog:",
"lint-staged": "catalog:",
"merge-stream": "catalog:",
"merge2": "catalog:",
"oslllo-svg-fixer": "catalog:",
"rimraf": "catalog:",
"svg-parser": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/gulp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { series } from 'gulp';

import { transform } from '@svgr/core';
import fs from 'fs-extra';
import upperCamelCase from 'uppercamelcase';
import path from 'path';
import { clearDir } from '../../../gulp/clean-dir';
import { upperCamelCase } from '../../../gulp/util';

const svgDir = path.join(__dirname, '../../../svg');
const srcDir = path.join(__dirname, '../src');
Expand Down
4 changes: 1 addition & 3 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
"@svgr/core": "catalog:",
"@svgr/plugin-prettier": "catalog:",
"@svgr/plugin-svgo": "catalog:",
"@types/uppercamelcase": "catalog:types",
"fs-extra": "catalog:",
"path": "catalog:",
"uppercamelcase": "catalog:"
"path": "catalog:"
}
}
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@rollup/plugin-commonjs": "catalog:",
"@rollup/plugin-node-resolve": "catalog:",
"@rollup/plugin-replace": "catalog:",
"@rollup/plugin-terser": "catalog:",
"@types/node": "catalog:types",
"@types/react": "catalog:types",
"@types/react-dom": "catalog:types",
Expand All @@ -62,8 +63,8 @@
"esbuild": "catalog:",
"less": "catalog:",
"postcss": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
"react": "catalog:react",
"react-dom": "catalog:react",
"rollup": "catalog:",
"rollup-plugin-esbuild": "catalog:",
"rollup-plugin-ignore-import": "catalog:",
Expand All @@ -72,7 +73,6 @@
"rollup-plugin-postcss": "catalog:",
"rollup-plugin-static-import": "catalog:",
"rollup-plugin-styles": "catalog:",
"rollup-plugin-terser": "catalog:",
"typescript": "catalog:"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
import multiInput from 'rollup-plugin-multi-input';
import postcss from 'rollup-plugin-postcss';
import esbuild from 'rollup-plugin-esbuild';
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';

const extensions = ['.ts', '.tsx'];

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@rollup/plugin-commonjs": "catalog:",
"@rollup/plugin-node-resolve": "catalog:",
"@rollup/plugin-replace": "catalog:",
"@rollup/plugin-terser": "catalog:",
"@vue/babel-plugin-jsx": "catalog:",
"@vue/babel-preset-jsx": "catalog:",
"@types/node": "catalog:types",
Expand All @@ -63,7 +64,6 @@
"rollup-plugin-postcss": "catalog:",
"rollup-plugin-static-import": "catalog:",
"rollup-plugin-styles": "catalog:",
"rollup-plugin-terser": "catalog:",
"rollup-plugin-vue": "catalog:",
"typescript": "catalog:",
"vue": "catalog:vue"
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-next/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import vuePlugin from 'rollup-plugin-vue';
import esbuild from 'rollup-plugin-esbuild';
import ignoreImport from 'rollup-plugin-ignore-import';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';

const extensions = ['.ts', '.tsx'];

Expand Down
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@rollup/plugin-commonjs": "catalog:",
"@rollup/plugin-node-resolve": "catalog:",
"@rollup/plugin-replace": "catalog:",
"@rollup/plugin-terser": "catalog:",
"@types/node": "catalog:types",
"@vue/babel-plugin-jsx": "catalog:",
"@vue/babel-preset-jsx": "catalog:",
Expand All @@ -67,7 +68,6 @@
"rollup-plugin-postcss": "catalog:",
"rollup-plugin-static-import": "catalog:",
"rollup-plugin-styles": "catalog:",
"rollup-plugin-terser": "catalog:",
"rollup-plugin-vue": "catalog:",
"tslib": "catalog:",
"typescript": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import vuePlugin from 'rollup-plugin-vue';
import esbuild from 'rollup-plugin-esbuild';
import ignoreImport from 'rollup-plugin-ignore-import';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';

const extensions = ['.ts', '.tsx'];

Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@rollup/plugin-json": "catalog:",
"@rollup/plugin-node-resolve": "catalog:",
"@rollup/plugin-replace": "catalog:",
"@rollup/plugin-terser": "catalog:",
"@types/node": "catalog:types",
"camelcase": "catalog:",
"concurrently": "catalog:",
Expand All @@ -66,7 +67,6 @@
"rollup-plugin-postcss": "catalog:",
"rollup-plugin-static-import": "catalog:",
"rollup-plugin-styles": "catalog:",
"rollup-plugin-terser": "catalog:",
"tslib": "catalog:",
"typescript": "catalog:"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
import multiInput from 'rollup-plugin-multi-input';
import postcss from 'rollup-plugin-postcss';
import esbuild from 'rollup-plugin-esbuild';
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import json from '@rollup/plugin-json';
import copy from 'rollup-plugin-copy';

Expand Down
Loading