-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
124 lines (111 loc) · 4.04 KB
/
gulpfile.js
File metadata and controls
124 lines (111 loc) · 4.04 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require("gulp-notify");
var minifyHTML = require('gulp-minify-html');
var insert = require('gulp-insert');
var htmlJsStr = require('js-string-escape');
var tap = require('gulp-tap');
var es = require('event-stream');
// Set directory for sample application file-loading
var filesPath = 'sample_application/';
var StandaloneFiles = ['bower_components/angular/angular.js',
'bower_components/angular-ui-router/release/angular-ui-router.js',
'bower_components/angular-touch/angular-touch.js',
'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'release/SlimUI.js'];
var StandaloneMinFiles = ['bower_components/angular/angular.min.js',
'bower_components/angular-ui-router/release/angular-ui-router.min.js',
'bower_components/angular-touch/angular-touch.min.js',
'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
'release/SlimUI.min.js'];
// Lint Task
gulp.task('lint', function() {
return gulp.src(['src/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Clean Task
gulp.task('clean', function(){
return gulp.src('release/*.js', {read: false})
.pipe(clean());
});
// Build the Framework
gulp.task('SlimUI', function() {
return gulp.src('src/*.js')
.pipe(concat('SlimUI.js'))
.pipe(gulp.dest('release'));
});
gulp.task('SlimUImin', ['SlimUI'], function() {
return gulp.src('release/SlimUI.js')
.pipe(uglify({output: { ascii_only: true}}))
.pipe(rename('SlimUI.min.js'))
.pipe(gulp.dest('release'));
});
// Builds the Framework with all dependencies included.
gulp.task('SlimUIStandalone', ['SlimUI'], function() {
return gulp.src(StandaloneFiles)
.pipe(concat('SlimUIStandalone.js'))
.pipe(gulp.dest('release'));
});
gulp.task('SlimUIStandaloneMin', ['SlimUImin'], function() {
return gulp.src(StandaloneMinFiles)
.pipe(concat('SlimUIStandalone.min.js'))
.pipe(uglify({output: { ascii_only: true}}))
.pipe(gulp.dest('release'));
});
// Build the Sample Application scripts
function buildScripts(){
return gulp.src(filesPath + '**/*.js')
.pipe(concat('compiledJS.js'))
.pipe(gulp.dest(''));
}
// Build the Sample Application HTML into JS
function buildHTML(){
var fileName ='';
return gulp.src(filesPath + '**/*.html')
.pipe(minifyHTML({quotes: true, empty: true}))
.pipe(tap(function(file) {
var nameS = file.path.split("\\");
var name = nameS[nameS.length -1];
name= name.replace(".html", "");
fileName = name + "Template";
}))
.pipe(insert.transform(function(contents) {
contents = htmlJsStr(contents);
contents = "var "+ fileName+ " = '" + contents + "';";
return contents;
}))
.pipe(concat('compiledTemplates.html'))
.pipe(gulp.dest(''));
}
// Build scripts and html separately
gulp.task('SampleApplicationParts', function() {
return es.merge(
buildScripts(),
buildHTML()
);
});
// Concatinate scripts and html into one file
function mergeAll(){
return gulp.src(['compiledJS.js', 'compiledTemplates.html'])
.pipe( concat('sample-application.js'))
.pipe( gulp.dest(''));
}
// Build the Sample Application by merging together the built JS and HTML-as-JS files.
// Require 'SampleApplicationParts' to be completed before this task runs
gulp.task('SampleApplication', ['SampleApplicationParts'], function(){
return es.merge(
mergeAll()
);
});
// Provide a default task that builds everything
gulp.task('default', ['lint', 'clean', 'SlimUIStandalone', 'SlimUIStandaloneMin', 'SampleApplication']);
gulp.task('watch', ['default'], function(){
gulp.watch(['src/**', 'sample_application/**'], ['default']);
});