forked from tonysamperi/ngx-mat-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
96 lines (85 loc) · 2.33 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
87
88
89
90
91
92
93
94
95
96
"use strict";
function logStart(msg) {
console.info("***** Task '" + msg + "' started *****");
}
function logEnd(msg) {
console.info("***** Task '" + msg + "' finished *****");
}
const gulp = require("gulp"),
path = require("path"),
runSequence = require("run-sequence"),
exec = require("child_process").exec,
sass = require("gulp-sass"),
tildeImporter = require("node-sass-tilde-importer")
;
const libName = "ngx-mat-lib";
const rootFolder = path.join(__dirname);
const srcFolder = path.join(rootFolder, `projects/${libName}/src/lib`);
const distFolder = path.join(rootFolder, `dist/${libName}`);
const distCssFolder = path.join(distFolder, "css");
const taskNames = {
ngBuild: "ngBuild",
main: "build",
mdsCopy: "mdsCopy",
pack: "pack",
stylesCopy: "copy:scss",
stylesBuild: "build:scss"
};
gulp.task(taskNames.ngBuild, (cb) => {
logStart(taskNames.ngBuild);
exec(`ng build ${libName}`, (err, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
logEnd(taskNames.ngBuild);
cb(err);
});
});
gulp.task(taskNames.stylesBuild, (cb) => {
logStart(taskNames.stylesBuild);
gulp.src([
`${srcFolder}/scss/xmat-library.scss`,
])
.pipe(sass({
importer: tildeImporter
}))
.pipe(gulp.dest(distCssFolder));
logEnd(taskNames.stylesBuild);
cb();
});
gulp.task(taskNames.stylesCopy, (cb) => {
logStart(taskNames.stylesCopy);
gulp.src([
`${srcFolder}/**/*.scss`,
])
.pipe(gulp.dest(distFolder));
logEnd(taskNames.stylesCopy);
cb();
});
gulp.task(taskNames.mdsCopy, (cb) => {
logStart(taskNames.mdsCopy);
gulp.src([
path.join(rootFolder, "changelog.md"),
path.join(rootFolder, "README.md")
])
.pipe(gulp.dest(distFolder));
logEnd(taskNames.mdsCopy);
cb();
});
// PACK
gulp.task(taskNames.pack, (cb) => {
logStart(taskNames.pack);
exec(`npm pack ./dist/${libName}`, (err, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
logEnd(taskNames.pack);
cb(err);
});
});
// MAIN
gulp.task(taskNames.main, function (cb) {
logStart(taskNames.main);
runSequence(taskNames.ngBuild, taskNames.stylesBuild, [taskNames.stylesCopy, taskNames.mdsCopy], (err) => {
logEnd(taskNames.main);
cb(err)
});
});