@@ -4,6 +4,7 @@ var gulp = require("gulp"),
4
4
concat = require ( "gulp-concat" ) ,
5
5
uglify = require ( "gulp-uglify" ) ,
6
6
wrap = require ( "gulp-wrap" ) ,
7
+ addsrc = require ( 'gulp-add-src' ) ,
7
8
minifyCSS = require ( "gulp-minify-css" ) ,
8
9
htmlReplace = require ( "gulp-html-replace" ) ,
9
10
header = require ( "gulp-header" ) ,
@@ -29,15 +30,10 @@ gulp.task("clean", function () {
29
30
} ) ;
30
31
31
32
gulp . task ( "gatherScripts" , [ "clean" ] , function ( ) {
32
- return gulp . src ( [
33
- "web/jsLib/joint.min.js" ,
34
- "web/jsLib/joint.shapes.uml.js" ,
35
- "web/jsLib/joint.layout.DirectedGraph.min.js" ,
36
- "web/js/*.js"
37
- ] )
33
+ return gulp . src ( "web/js/*.js" )
38
34
. pipe ( concat ( "CacheUMLExplorer.js" ) )
39
35
. pipe ( replace ( / \/ \* \{ \{ r e p l a c e : v e r s i o n } } \* \/ / , "\"" + pkg [ "version" ] + "\"" ) )
40
- // .pipe(wrap("CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());"))
36
+ . pipe ( wrap ( "CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());" ) )
41
37
. pipe ( uglify ( {
42
38
output : {
43
39
ascii_only : true ,
@@ -46,24 +42,19 @@ gulp.task("gatherScripts", ["clean"], function () {
46
42
}
47
43
} ) )
48
44
. pipe ( header ( banner , { pkg : pkg } ) )
45
+ . pipe ( addsrc . prepend ( [
46
+ "web/jsLib/joint.min.js" ,
47
+ "web/jsLib/joint.shapes.uml.js" ,
48
+ "web/jsLib/joint.layout.DirectedGraph.min.js"
49
+ ] ) )
50
+ . pipe ( concat ( "CacheUMLExplorer.js" ) )
49
51
. pipe ( gulp . dest ( "build/web/js/" ) ) ;
50
52
} ) ;
51
53
52
- //gulp.task("concatScripts", ["gatherScripts"], function () {
53
- // return gulp.src([
54
- // "web/jsLib/joint.min.js",
55
- // "web/jsLib/joint.layout.DirectedGraph.min.js",
56
- // "web/jsLib/joint.shapes.uml.js",
57
- // "build/web/js/CacheUMLExplorer.js"
58
- // ])
59
- // .pipe(concat("CacheUMLExplorer.js"))
60
- // .pipe(gulp.dest("build/web/js/"));
61
- //});
62
-
63
54
gulp . task ( "gatherCSS" , [ "clean" ] , function ( ) {
64
55
return gulp . src ( "web/css/*.css" )
65
56
. pipe ( concat ( "CacheUMLExplorer.css" ) )
66
- . pipe ( minifyCSS ( ) )
57
+ . pipe ( minifyCSS ( { keepSpecialComments : 0 } ) )
67
58
. pipe ( gulp . dest ( "build/web/css/" ) ) ;
68
59
} ) ;
69
60
@@ -76,16 +67,6 @@ gulp.task("addHTMLFile", ["clean"], function () {
76
67
. pipe ( gulp . dest ( "build/web/" ) ) ;
77
68
} ) ;
78
69
79
- gulp . task ( "addHTMLZIPFile" , [ "clean" , "gatherScripts" , "gatherCSS" ] , function ( ) {
80
- var jsRepl = "<script type='text/javascript'>" + fs . readFileSync ( "build/web/js/CacheUMLExplorer.js" , "utf-8" ) + "</script>" ,
81
- cssRepl = "<style type='text/css'>" + fs . readFileSync ( "build/web/css/CacheUMLExplorer.css" ) + "</style>" ;
82
- return gulp . src ( "web/index.html" )
83
- . pipe ( concat ( "ZIPindex.html" ) )
84
- . pipe ( replace ( / < ! \- \- b u i l d : j s \- \- > ( .| \r | \n ) * < ! \- \- e n d b u i l d \- \- > / , function ( ) { return jsRepl ; } ) )
85
- . pipe ( replace ( / < ! \- \- b u i l d : c s s \- \- > ( .| \r | \n ) * < ! \- \- e n d b u i l d \- \- > / , function ( ) { return cssRepl ; } ) )
86
- . pipe ( gulp . dest ( "build/web" ) ) ;
87
- } ) ;
88
-
89
70
gulp . task ( "copyLICENSE" , [ "clean" ] , function ( ) {
90
71
return gulp . src ( "LICENSE" )
91
72
. pipe ( gulp . dest ( "build/" ) ) ;
@@ -97,13 +78,18 @@ gulp.task("copyREADME", ["clean"], function (){
97
78
} ) ;
98
79
99
80
gulp . task ( "exportCacheXML" , [
100
- "clean" , "gatherCSS" , "addHTMLFile " , "addHTMLZIPFile " , "copyLICENSE" , "copyREADME"
81
+ "clean" , "gatherCSS" , "gatherScripts " , "addHTMLFile " , "copyLICENSE" , "copyREADME"
101
82
] , function ( ) {
102
83
return gulp . src ( "cache/projectTemplate.xml" )
103
- . pipe (
104
- replace ( / \{ \{ r e p l a c e : H T M L } } / ,
105
- fs . readFileSync ( "build/web/ZIPindex.html" , "utf-8" ) )
106
- )
84
+ . pipe ( replace ( / \{ \{ r e p l a c e : H T M L } } / , fs . readFileSync ( "build/web/index.html" , "utf-8" ) ) )
85
+ . pipe ( replace (
86
+ / \{ \{ r e p l a c e : c s s } } / ,
87
+ fs . readFileSync ( "build/web/css/CacheUMLExplorer.css" , "utf-8" )
88
+ ) )
89
+ . pipe ( replace (
90
+ / \{ \{ r e p l a c e : j s } } / ,
91
+ fs . readFileSync ( "build/web/js/CacheUMLExplorer.js" , "utf-8" )
92
+ ) )
107
93
. pipe ( rename ( function ( path ) { path . basename += "-v" + pkg [ "version" ] ; } ) )
108
94
. pipe ( gulp . dest ( "build/Cache" ) ) ;
109
95
} ) ;
0 commit comments