-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
65 lines (58 loc) · 1.65 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
const gulp = require('gulp');
const htmlMinifier = require('html-minifier');
const inlineNg2Template = require('gulp-inline-ng2-template');
const sass = require('gulp-sass');
const cleanCSS = require('gulp-clean-css');
const sequence = require('gulp-sequence');
const del = require('del');
function minifyTemplate(path, ext, file, cb) {
try {
var minifiedFile = htmlMinifier.minify(file, {
collapseWhitespace: true,
caseSensitive: true,
removeComments: true,
removeRedundantAttributes: true,
minifyCSS: true,
removeComments: true
});
cb(null, minifiedFile);
} catch (err) {
cb(err);
}
}
gulp.task('copy:temp', function () {
return gulp.src(['./src/amp-dash/**/*.*'])
.pipe(gulp.dest('./src/temp'));
});
gulp.task('css', function () {
return gulp.src(['./src/temp/**/*.scss'])
.pipe(sass())
.pipe(cleanCSS())
.pipe(gulp.dest('./src/temp'));
});
gulp.task('inline', function () {
return gulp.src(['./src/temp/**/*.ts'])
.pipe(inlineNg2Template({
base: '/src/temp',
useRelativePaths: true,
templateProcessor: minifyTemplate,
removeLineBreaks:true
}))
.pipe(gulp.dest('./src/temp'));
});
gulp.task('clean:before', function () {
return del([
'temp',
'dist',
'lib',
'aot',
'src/temp'
]);
});
gulp.task('clean:after', function () {
return del([
'src/temp'
]);
});
gulp.task('pre:build', sequence('clean:before', 'copy:temp', 'css', 'inline'));
gulp.task('post:build', sequence('clean:after'));