-
Notifications
You must be signed in to change notification settings - Fork 59
/
gulpfile.default.js
80 lines (70 loc) · 2 KB
/
gulpfile.default.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
"use strict";
var gulp = require('gulp');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var uglify = require("gulp-uglify");
var gulpif = require('gulp-if');
var useref = require('gulp-useref');
var del = require('del');
var gzip = require('gulp-gzip');
var filter = require('gulp-filter');
var replace = require('gulp-replace');
var less = require('gulp-less');
var moment = require('moment');
var oss = require("gulp-oss");
var config = require('./config.js');
var paths = {
template: ['./tpl/**/*.html'],
less: ['./css/less/*.less'],
fonts: ['./fonts/**/*.{ttf,woff,eot,svg}'],
images: ['./images/**/*.{png,jpg,gif}'],
dist: ['./dist']};
gulp.task('build', ['cleanDist', 'templates', 'less'], function (done) {
var assets = useref.assets();
gulp.src(paths.fonts)
.pipe(gulp.dest('./dist/fonts'));
gulp.src(paths.images)
.pipe(gulp.dest('./dist/images'));
gulp.src(['./player.html', './editor.html'])
.pipe(assets)
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', minifyCss()))
.pipe(assets.restore())
.pipe(useref())
.pipe(gulp.dest('dist'))
.on('end', done);
});
gulp.task('less', function () {
gulp.src(['./css/less/app.less', './css/less/player.less'])
.pipe(less({
paths: ['./css/less']
}))
.pipe(gulp.dest('./css'));
});
gulp.task('cleanDist', function (cb) {
del(['./dist'], cb);
});
gulp.task('templates', function (done) {
gulp.src(paths.template)
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(ngHtml2Js({
moduleName: "app.tpls",
prefix: "/tpl/"
}))
.pipe(concat("tpls.min.js"))
.pipe(uglify())
.pipe(gulp.dest("./js"))
.on('end', done);
});
gulp.task('watch', function () {
gulp.watch(paths.template, ['templates']);
gulp.watch(paths.less, ['less']);
});