forked from IgniteUI/igniteui-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
99 lines (79 loc) · 2.46 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
97
98
99
"use strict";
const autoprefixer = require("autoprefixer");
const gulp = require("gulp");
const sass = require("node-sass");
const postcss = require("postcss");
const inlineTemplates = require("gulp-inline-ng2-template");
const exec = require("child_process").exec;
const fs = require("fs");
const prefixer = postcss([autoprefixer({
browsers: ["last 5 versions", "> 3%"],
cascade: false,
grid: true
})]);
function compileSass(path, ext, file, callback) {
let compiledCss = sass.renderSync({
file: path,
outputStyle: "compressed"
});
callback(null, prefixer.process(compiledCss.css).css);
}
const INLINE_TEMPLATES = {
SRC: "./src/**/*.ts",
DIST: "./tmp/src-inlined",
CONFIG: {
base: "/src",
target: "es6",
removeLineBreaks: true,
useRelativePaths: true,
styleProcessor: compileSass
}
};
const FONTS = {
SRC: [
"node_modules/material-design-icons/iconfont/*.{woff,woff2,ttf}",
"src/fonts/titillium/*.ttf",
"src/fonts/titillium/*.txt"
],
DIST: "dist/fonts"
};
gulp.task("make-packagejson", () => {
fs.readFile("package.json", "utf8", (err, data) => {
if (err) throw err;
data = JSON.parse(data.trim());
delete data.scripts;
delete data.devDependencies;
data.peerDependencies = data.dependencies;
delete data.dependencies;
fs.writeFile("dist/package.json", JSON.stringify(data, null, 4), "utf8", (err) => {
if (err) throw err;
});
});
});
gulp.task("build-style", () => {
let result = sass.renderSync({
file: "src/themes/igniteui-angular.scss",
outputStyle: "compressed",
includePaths: ["./src/themes"],
outFile: "dist/igniteui-angular.css"
});
fs.writeFile("dist/igniteui-angular.css", prefixer.process(result.css).css, (err) => {
if (err) throw err;
});
return gulp.src(FONTS.SRC)
.pipe(gulp.dest(FONTS.DIST));
});
gulp.task("inline-templates", () => {
return gulp.src(INLINE_TEMPLATES.SRC)
.pipe(inlineTemplates(INLINE_TEMPLATES.CONFIG))
.pipe(gulp.dest(INLINE_TEMPLATES.DIST));
});
gulp.task("build:esm", ["inline-templates"], (callback) => {
exec("npm run ngcompile", function (err, stdout, stderr) {
console.log(stdout, stderr);
callback(err);
});
});
gulp.task("build:esm:watch", ["build:esm"], () => {
gulp.watch("src/**/*", ["build:esm", "build-style"]);
});