-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
49 lines (42 loc) · 1.08 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
const gulp = require('gulp');
const sass = require('node-sass');
const inline = require('gulp-inline-ng2-template');
const htmlmin = require('html-minifier');
const tsconfig = require('./tsconfig.json');
const INLINE_TEMPLATES = {
SRC: './src/**/*.ts',
DST: './.tmp',
CFG: {
base: '/src',
target: tsconfig.compilerOptions.target,
useRelativePaths: true,
removeLineBreaks: true,
templateProcessor: minifyHtml,
styleProcessor: compileSass
}
};
function minifyHtml(path, ext, file, callback) {
try {
let content = htmlmin.minify(file, {
collapseWhitespace: true,
caseSensitive: true,
removeComments: true,
removeRedundantAttributes: true
});
callback(null, content);
} catch (err) {
callback(err);
}
}
function compileSass(path, ext, file, callback) {
let compiled = sass.renderSync({
file: path,
outputStyle: 'compressed'
});
callback(null, compiled.css);
}
gulp.task('inline', () => {
return gulp.src(INLINE_TEMPLATES.SRC)
.pipe(inline(INLINE_TEMPLATES.CFG))
.pipe(gulp.dest(INLINE_TEMPLATES.DST));
});