@@ -4,6 +4,7 @@ var gulp = require("gulp"),
44 concat = require ( "gulp-concat" ) ,
55 uglify = require ( "gulp-uglify" ) ,
66 wrap = require ( "gulp-wrap" ) ,
7+ addsrc = require ( 'gulp-add-src' ) ,
78 minifyCSS = require ( "gulp-minify-css" ) ,
89 htmlReplace = require ( "gulp-html-replace" ) ,
910 header = require ( "gulp-header" ) ,
@@ -29,15 +30,10 @@ gulp.task("clean", function () {
2930} ) ;
3031
3132gulp . 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" )
3834 . pipe ( concat ( "CacheUMLExplorer.js" ) )
3935 . 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;}());" ) )
4137 . pipe ( uglify ( {
4238 output : {
4339 ascii_only : true ,
@@ -46,24 +42,19 @@ gulp.task("gatherScripts", ["clean"], function () {
4642 }
4743 } ) )
4844 . 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" ) )
4951 . pipe ( gulp . dest ( "build/web/js/" ) ) ;
5052} ) ;
5153
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-
6354gulp . task ( "gatherCSS" , [ "clean" ] , function ( ) {
6455 return gulp . src ( "web/css/*.css" )
6556 . pipe ( concat ( "CacheUMLExplorer.css" ) )
66- . pipe ( minifyCSS ( ) )
57+ . pipe ( minifyCSS ( { keepSpecialComments : 0 } ) )
6758 . pipe ( gulp . dest ( "build/web/css/" ) ) ;
6859} ) ;
6960
@@ -76,16 +67,6 @@ gulp.task("addHTMLFile", ["clean"], function () {
7667 . pipe ( gulp . dest ( "build/web/" ) ) ;
7768} ) ;
7869
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-
8970gulp . task ( "copyLICENSE" , [ "clean" ] , function ( ) {
9071 return gulp . src ( "LICENSE" )
9172 . pipe ( gulp . dest ( "build/" ) ) ;
@@ -97,13 +78,18 @@ gulp.task("copyREADME", ["clean"], function (){
9778} ) ;
9879
9980gulp . task ( "exportCacheXML" , [
100- "clean" , "gatherCSS" , "addHTMLFile " , "addHTMLZIPFile " , "copyLICENSE" , "copyREADME"
81+ "clean" , "gatherCSS" , "gatherScripts " , "addHTMLFile " , "copyLICENSE" , "copyREADME"
10182] , function ( ) {
10283 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+ ) )
10793 . pipe ( rename ( function ( path ) { path . basename += "-v" + pkg [ "version" ] ; } ) )
10894 . pipe ( gulp . dest ( "build/Cache" ) ) ;
10995} ) ;
0 commit comments