@novlan/postcss-plugin-remove-selector 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1,13 +1,2 @@
1
- import type { Options, PostCSSPlugin } from './types';
2
- export type { Options, FileConfig, ShouldRemoveRuleOptions, PostCSSPlugin } from './types';
3
- export { shouldHandleFile, shouldRemoveRule, extractIconName } from './helper';
4
- /**
5
- * PostCSS 插件:移除指定的 CSS 选择器
6
- * 用于图标样式减包等场景
7
- *
8
- * @param opts 配置项
9
- * @returns PostCSS 插件
10
- */
11
- export declare function postCssPluginRemoveSelector(opts?: Options): PostCSSPlugin & {
12
- postcss: true;
13
- };
1
+ export * from './plugin';
2
+ export { TDESIGN_ICON_REMOVE_SELECTOR } from './tdesign-uniapp-icon';
package/lib/index.js CHANGED
@@ -90,6 +90,94 @@ function postCssPluginRemoveSelector(opts = { list: [] }) {
90
90
  return plugin;
91
91
  }
92
92
 
93
+ /**
94
+ * TDesign UniApp 图标减包配置
95
+ *
96
+ * 使用说明:
97
+ * 1. 在 USED_ICONS 数组中配置项目中实际使用的图标名称
98
+ * 2. 插件只会处理 .t-icon-xxx:before 这类图标选择器
99
+ * 3. 其他基础样式(如 @font-face、.t-icon 等)会自动保留
100
+ *
101
+ * 如何查找项目中使用的图标:
102
+ * grep -rho 'icon="[^"]*"\|left-icon="[^"]*"\|name="[^"]*"' src --include="*.vue" | sort | uniq
103
+ */
104
+ /**
105
+ * 项目中实际使用的图标列表
106
+ * 根据 src 目录下的 .vue 文件分析得出
107
+ */
108
+ const USED_ICONS = [
109
+ // custom-tab-bar.vue
110
+ 'home',
111
+ 'chat',
112
+ 'user',
113
+ // home/index.vue
114
+ 'add',
115
+ // release/index.vue
116
+ 'location',
117
+ 'file-copy',
118
+ 'upload',
119
+ // search/index.vue
120
+ 'search',
121
+ 'delete',
122
+ // data-center/index.vue
123
+ 'info-circle-filled',
124
+ // my/index.vue - 静态图标
125
+ 'discount',
126
+ 'edit',
127
+ // my/index.vue - gridList 动态图标
128
+ 'root-list',
129
+ // my/index.vue - settingList 动态图标
130
+ 'service',
131
+ 'setting',
132
+ // setting/index.vue - menuData 动态图标
133
+ 'app',
134
+ 'notification',
135
+ 'image',
136
+ 'chart',
137
+ 'sound',
138
+ 'secured',
139
+ 'info-circle',
140
+ // login/login.vue
141
+ 'logo-wechat-stroke',
142
+ 'logo-qq',
143
+ 'logo-wecom',
144
+ 'caret-down-small',
145
+ // nav-bar.vue
146
+ 'view-list',
147
+ // 组件内部可能使用的图标(如 t-navbar left-arrow 等)
148
+ 'chevron-left',
149
+ 'chevron-right',
150
+ 'chevron-up',
151
+ 'chevron-down',
152
+ 'arrow-left',
153
+ 'arrow-right',
154
+ 'arrow-up',
155
+ 'arrow-down',
156
+ 'close',
157
+ 'close-circle-filled',
158
+ 'check',
159
+ 'check-circle-filled',
160
+ 'error-circle-filled',
161
+ 'loading',
162
+ ];
163
+ /**
164
+ * TDesign UniApp 图标减包配置
165
+ */
166
+ const TDESIGN_ICON_REMOVE_SELECTOR = {
167
+ list: [
168
+ {
169
+ // 匹配 @tdesign/uniapp 的图标 css 文件
170
+ file: /[@/]tdesign[/]uniapp[/]dist[/]icon[/]icon\.[css|vue]/,
171
+ // 只处理 .t-icon-xxx:before 这类图标选择器,其他样式自动保留
172
+ selectorPattern: /^\.t-icon-[\w-]+:before$/,
173
+ // 保留的图标名称列表
174
+ include: USED_ICONS,
175
+ exclude: [],
176
+ },
177
+ ],
178
+ };
179
+
180
+ exports.TDESIGN_ICON_REMOVE_SELECTOR = TDESIGN_ICON_REMOVE_SELECTOR;
93
181
  exports.extractIconName = extractIconName;
94
182
  exports.postCssPluginRemoveSelector = postCssPluginRemoveSelector;
95
183
  exports.shouldHandleFile = shouldHandleFile;
@@ -0,0 +1,13 @@
1
+ import type { Options, PostCSSPlugin } from './types';
2
+ export type { Options, FileConfig, ShouldRemoveRuleOptions, PostCSSPlugin } from './types';
3
+ export { shouldHandleFile, shouldRemoveRule, extractIconName } from './helper';
4
+ /**
5
+ * PostCSS 插件:移除指定的 CSS 选择器
6
+ * 用于图标样式减包等场景
7
+ *
8
+ * @param opts 配置项
9
+ * @returns PostCSS 插件
10
+ */
11
+ export declare function postCssPluginRemoveSelector(opts?: Options): PostCSSPlugin & {
12
+ postcss: true;
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novlan/postcss-plugin-remove-selector",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "homepage": "https://novlan1.github.io/plugins/zh/postcss-plugin-remove-selector.html",
5
5
  "bugs": {
6
6
  "url": "https://github.com/novlan1/plugins/issues"