-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
80 lines (71 loc) · 1.88 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
const {src, dest, task, series, parallel} = require("gulp");
const clean = require("gulp-clean");
const less = require("gulp-less");
const autoprefix = require("gulp-autoprefixer");
const minifyCSS = require("gulp-csso");
const rename = require("gulp-rename");
const uglify = require("gulp-uglify");
const {build} = require("./src/build/index")
const config = require('./src/build/config.json')
// 清除目录
task("clean", () => {
return src([config.apiHome, config.distHome, config.modelReadme], {
read: false,
allowEmpty: true,
}).pipe(
clean({
force: true,
})
);
});
// 创建模型的json文件
task("build", (done) => {
build()
done()
})
// 编译压缩css
task("css", () => {
const ignoreFiles = [].map((file) => `./src/driver/${file}.less`);
return src("./src/driver/*.less", {
ignore: ignoreFiles,
})
.pipe(less())
.pipe(
autoprefix({
overrideBrowserslist: ["> 2%", "last 2 versions", "not ie 6-9"],
cascade: false,
})
)
.pipe(minifyCSS())
.pipe(
rename({
suffix: ".min",
})
)
.pipe(dest(config.distHome));
});
// 压缩js
task("js", () => {
const ignoreFiles = [].map((file) => `./src/driver/${file}.js`);
return src("./src/driver/*.js", {
ignore: ignoreFiles,
})
.pipe(uglify())
.pipe(
rename({
suffix: ".min",
})
)
.pipe(dest(config.distHome));
});
// 拷贝资源
task("assets", () => {
return src('src/driver/*', {
ignore: ['**/*.{less,scss}']
})
.pipe(dest(config.distHome))
})
// 编译
task("compile", series("clean", parallel("css", "js", "assets")));
// 默认模式
task("default", series("clean", "build", parallel("css", "js", "assets")));