This repository was archived by the owner on Dec 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
72 lines (60 loc) · 2.21 KB
/
gulpfile.js
File metadata and controls
72 lines (60 loc) · 2.21 KB
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
var gulp = require('gulp');
var meta = require('./package.json');
var addStream = require('add-stream');
var concat = require('gulp-concat');
var expect = require('gulp-expect-file');
var htmlMinifier = require('gulp-html-minifier');
var inject = require('gulp-inject-string');
var rename = require('gulp-rename');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
// Paths ----------------------------------------------------------------------
var BASE = 'dev/yatable';
var DIST = '.';
var templateFiles = [
BASE + '/static/table.html',
BASE + '/static/controls.html',
BASE + '/static/dropdown.html',
BASE + '/static/row.html',
BASE + '/static/paging.html'
];
var mainFile = BASE + '/static/js/yaat.js';
// Options --------------------------------------------------------------------
var outFilename = 'yaat.full.js';
var minifiedOutFilename = 'yaat.min.js';
var cacheOptions = {
module: 'yaat',
root: 'yatable'
};
var prependString = '/*\n';
prependString += ' ' + meta.name + ' v' + meta.version + ' - https://github.com/slapec/yaat\n';
prependString += ' build date: ' + new Date().toISOString() + '\n';
prependString += '*/\n';
// Tasks ----------------------------------------------------------------------
gulp.task('minifyCss', function(){
var path = BASE + '/static/css/yaat.css';
return gulp.src(path)
.pipe(expect(path))
.pipe(minifyCss())
.pipe(inject.prepend(prependString))
.pipe(gulp.dest(DIST))
});
gulp.task('default', ['minifyCss'], function(){
var templates = gulp.src(templateFiles)
.pipe(expect(templateFiles))
.pipe(htmlMinifier({collapseWhitespace: true}))
.pipe(templateCache(cacheOptions));
gulp.src(mainFile)
.pipe(expect(mainFile))
.pipe(addStream.obj(templates))
.pipe(concat(outFilename))
.pipe(inject.prepend(prependString))
.pipe(gulp.dest(BASE + '/static/js/'))
.pipe(gulp.dest(DIST))
.pipe(uglify())
.pipe(inject.prepend(prependString))
.pipe(rename(minifiedOutFilename))
.pipe(gulp.dest(BASE + '/static/js'))
.pipe(gulp.dest(DIST))
});