-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
70 lines (57 loc) · 1.97 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
66
67
68
69
70
var gulp = require('gulp');
//Use gulp-load-plugins to auto require plugins
//The plugin name: transforms hyphenated plugins names to camel case
var plugins = require('gulp-load-plugins')();
/*
var ngHtml2Js = require("gulp-ng-html2js");
var concat = require("gulp-concat");
var clean = require("gulp-clean");
var ngAnnotate = require('gulp-ng-annotate');
var minifyCss = require('gulp-minify-css');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
*/
var _ = plugins.loadUtils(['log', 'colors', 'env']);
var eventStream = require('event-stream');
//read env variable
var _fileName = _.env['concat-file-name'] || "all.js";
var _uglify = _.env.uglify || false;
var _cssmini = _.env.cssmini || false;
var _moduleName = _.env['template-module-name'] || "cuf.template";
var _appModuleName = _.env['app-module-name'];
/*
--file-name ${{fileName}}
--uglify
--cssmini
--module-name ${{moduleName}}
*/
gulp.task('buildcss', ['clean'], function(){
return gulp.src('./src/css/*.css')
.pipe(plugins.if(_cssmini, plugins.minifyCss()))
.pipe(gulp.dest("./dist/css"));
});
gulp.task('clean', function(){
return gulp.src('./dist')
.pipe(plugins.clean({force: true}));
});
gulp.task('buildjs', ['clean'], function() {
var jsStream = gulp.src("./src/js/*.js"),
htmlStream = gulp.src("./src/template/*.html");
//_.log(_appModuleName);
var configObj = {};
configObj[_appModuleName] = [
_moduleName
];
//_.log(configObj);
jsStream.pipe(plugins.if(typeof _appModuleName !== 'undefined', plugins.angularExtender(configObj)));
htmlStream.pipe(plugins.ngHtml2js({
moduleName: _moduleName,
prefix: "template/"
}));
return eventStream.merge(jsStream, htmlStream)
.pipe(plugins.concat(_fileName))
.pipe(plugins.ngAnnotate())
.pipe(plugins.if(_uglify, plugins.uglify()))
.pipe(gulp.dest("./dist/js"))
});
gulp.task('default', ['clean', 'buildjs', 'buildcss']);