-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
gulpfile.js
86 lines (84 loc) · 3.14 KB
/
gulpfile.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const fs = require('fs')
const gulp = require('gulp')
const postcss = require('gulp-postcss')
const cssvars = require('postcss-css-variables')
const rename = require('gulp-rename')
const replace = require('gulp-replace')
const gulpIf = require('gulp-if')
const gulpIgnore = require('gulp-ignore')
gulp.task('transform-css-vars', () => {
const plugins = [
cssvars({
preserve: false,
variables: {
"--weui-BTN-DISABLED-FONT-COLOR": "rgba(0, 0, 0, .2)",
"--weui-BTN-DEFAULT-BG": "#f2f2f2",
"--weui-BTN-DEFAULT-COLOR": "#06ae56",
"--weui-BTN-DEFAULT-ACTIVE-BG": "#e6e6e6",
"--weui-DIALOG-LINE-COLOR": "rgba(0, 0, 0, .1)",
"--weui-BG-0": "#ededed",
"--weui-BG-1": "#f7f7f7",
"--weui-BG-2": "#fff",
"--weui-BG-3": "#f7f7f7",
"--weui-BG-4": "#4c4c4c",
"--weui-BG-5": "#fff",
"--weui-FG-0": "rgba(0, 0, 0, .9)",
"--weui-FG-HALF": "rgba(0, 0, 0, .9)",
"--weui-FG-1": "rgba(0, 0, 0, .5)",
"--weui-FG-2": "rgba(0, 0, 0, .3)",
"--weui-FG-3": "rgba(0, 0, 0, .1)",
"--weui-RED": "#fa5151",
"--weui-ORANGE": "#fa9d3b",
"--weui-YELLOW": "#ffc300",
"--weui-GREEN": "#91d300",
"--weui-LIGHTGREEN": "#95ec69",
"--weui-BRAND": "#07c160",
"--weui-BLUE": "#10aeff",
"--weui-INDIGO": "#1485ee",
"--weui-PURPLE": "#6467f0",
"--weui-WHITE": "#fff",
"--weui-LINK": "#576b95",
"--weui-TEXTGREEN": "#06ae56",
"--weui-FG": "#000",
"--weui-BG": "#fff",
"--weui-TAG-TEXT-ORANGE": "#fa9d3b",
"--weui-TAG-BACKGROUND-ORANGE": "rgba(250, 157, 59, .1)",
"--weui-TAG-TEXT-GREEN": "#06ae56",
"--weui-TAG-BACKGROUND-GREEN": "rgba(6, 174, 86, .1)",
"--weui-TAG-TEXT-BLUE": "#10aeff",
"--weui-TAG-BACKGROUND-BLUE": "rgba(16, 174, 255, .1)",
"--weui-TAG-TEXT-BLACK": "rgba(0, 0, 0, .5)",
"--weui-TAG-BACKGROUND-BLACK": "rgba(0, 0, 0, .05)",
"--weui-BG-COLOR-ACTIVE": "#ececec",
"--height": "44px",
"--right": "95px",
},
preserveInjectedVariables: false,
})
]
return gulp.src([
'./miniprogram/app.wxss',
'./miniprogram/common/common.wxss',
'./miniprogram/page/common/common.wxss',
'./miniprogram/page/common/index.wxss',
'./miniprogram/page/component/index.wxss',
'./miniprogram/page/cloud/index.wxss',
'./miniprogram/page/API/index.wxss',
'./miniprogram/page/extend/index.wxss',
'./miniprogram/packageComponent/pages/canvas/canvas-2d/canvas-2d.wxss',
])
.pipe(gulpIgnore.exclude(
file => {
try {
fs.accessSync(file.path.replace(/\.wxss$/, '-skyline.wxss'))
} catch(e) {
return false
}
return true
}))
.pipe(postcss(plugins))
.pipe(replace(/\:root ?{}\n/g, ''))
.pipe(gulpIf(file => file.path.includes('miniprogram/page/common'), rename({suffix: '-skyline'})))
.pipe(gulpIf(file => file.path.includes('miniprogram/common'), rename({suffix: '-skyline'})))
.pipe(gulp.dest(file => file.base))
})