forked from jfcere/ngx-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
40 lines (36 loc) · 1.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
const CleanCSS = require('clean-css');
const gulp = require('gulp');
const htmlMinifier = require('html-minifier');
const inlineNg2Template = require('gulp-inline-ng2-template');
const sass = require('node-sass');
function sassProcessor(path, ext, file, callback) {
if (ext[0] === '.scss') {
const sassObj = sass.renderSync({ file: path });
if (sassObj && sassObj['css']) {
file = new CleanCSS({})
.minify(sassObj.css.toString('utf8'))
.styles;
}
}
return callback(null, file);
};
function minifyTemplate(path, ext, file, callback) {
const minifiedFile = htmlMinifier.minify(file, {
caseSensitive: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
removeComments: true,
});
callback(null, minifiedFile);
}
gulp.task('inline-template', function () {
return gulp.src(['./src/app/markdown/**/*.ts', '!./src/app/markdown/*.spec.ts'])
.pipe(inlineNg2Template({
base: '/src/app/markdown',
removeLineBreaks: true,
styleProcessor: sassProcessor,
templateProcessor: minifyTemplate,
useRelativePaths: true,
}))
.pipe(gulp.dest('./inline-template'));
});