-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpostcss.config.js
More file actions
69 lines (65 loc) · 2.78 KB
/
postcss.config.js
File metadata and controls
69 lines (65 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const webpack = require('webpack');
const { postcssPluginRemoveSelector } = require('@novlan/postcss-plugin-remove-selector');
const { deepSelectorPlugin, rpxToPxPlugin } = require('t-comm');
const config = {
parser: require('postcss-comment'),
plugins: [
require('postcss-import')({
resolve(id) {
if (id.startsWith('~@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3));
} if (id.startsWith('@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2));
} if (id.startsWith('/') && !id.startsWith('//')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1));
}
return id;
},
}),
require('autoprefixer')({
remove: process.env.UNI_PLATFORM !== 'h5',
}),
// Vue3 :deep() 转 Vue2 ::v-deep,需要放在前面处理
deepSelectorPlugin(),
// 移除未使用的 tdesign 图标选择器,减少样式体积
postcssPluginRemoveSelector({
mode: 'tdesign',
customUsed: [
// 首页导航图标
'app', 'bulletpoint', 'chat', 'image', 'view-module',
// 通用操作图标
'add', 'close', 'check', 'search', 'delete', 'edit', 'edit-1', 'remove', 'refresh',
// 方向/导航图标
'chevron-down', 'chevron-up', 'chevron-left', 'chevron-right',
'chevron-left-double', 'chevron-right-double', 'enter', 'jump',
// 状态/提示图标
'check-circle', 'check-circle-filled', 'close-circle', 'error-circle', 'close-circle-filled',
'error-circle-filled', 'info-circle-filled', 'loading', 'success', 'check-rectangle-filled',
'minus-circle-filled',
// 业务图标
'bookmark', 'browse', 'browse-off', 'camera', 'cart', 'circle',
'cloud-upload', 'discount', 'dot', 'download', 'file-add', 'file-word-filled',
'gesture-press', 'home', 'internet', 'link', 'lock-on',
'notification', 'notification-filled', 'pin', 'poweroff', 'queue',
'rectangle', 'send-filled', 'service', 'share', 'shop', 'sound',
'star', 'star-filled', 'thumb-up', 'update',
'user', 'user-add', 'user-avatar', 'backtop',
'replay', 'copy', 'good', 'bad', 'share', 'thumb-down', 'thumb-up', 'share-1',
'file-excel-filled', 'file-pdf-filled', 'file-ppt-filled', 'file-word-filled',
'file-zip-filled', 'file-powerpoint-filled', 'video-filled',
'multiply',
],
}),
// rpx 转 px,内置仅在 h5 平台执行
// 必须放在 @dcloudio/vue-cli-plugin-uni/packages/postcss 之前
rpxToPxPlugin(),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')({
include: /node_modules\/.*/
}),
],
};
if (webpack.version[0] > 4) {
delete config.parser;
}
module.exports = config;