@@ -4,6 +4,7 @@ var gulp = require("gulp"),
44 concat = require ( "gulp-concat" ) ,
55 uglify = require ( "gulp-uglify" ) ,
66 wrap = require ( "gulp-wrap" ) ,
7+ stripComments = require ( "gulp-strip-comments" ) ,
78 addsrc = require ( 'gulp-add-src' ) ,
89 minifyCSS = require ( "gulp-minify-css" ) ,
910 htmlReplace = require ( "gulp-html-replace" ) ,
@@ -14,6 +15,7 @@ var gulp = require("gulp"),
1415 rename = require ( "gulp-rename" ) ;
1516
1617var banner = [
18+ "" ,
1719 "/** <%= pkg.name %>" ,
1820 " ** <%= pkg.description %>" ,
1921 " ** @author <%= pkg.author %>" ,
@@ -29,24 +31,40 @@ gulp.task("clean", function () {
2931 . pipe ( clean ( ) ) ;
3032} ) ;
3133
32- gulp . task ( "gatherScripts" , [ "clean" ] , function ( ) {
33- return gulp . src ( "web/js/*.js" )
34- . pipe ( concat ( "CacheUMLExplorer.js" ) )
35- . pipe ( replace ( / \/ \* \{ \{ r e p l a c e : v e r s i o n } } \* \/ / , "\"" + pkg [ "version" ] + "\"" ) )
36- . pipe ( wrap ( "CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());" ) )
34+ gulp . task ( "gatherLibs" , [ "clean" ] , function ( ) {
35+ return gulp . src ( [
36+ "web/jsLib/joint.shapes.uml.js"
37+ ] )
3738 . pipe ( uglify ( {
3839 output : {
3940 ascii_only : true ,
4041 width : 30000 ,
4142 max_line_len : 30000
4243 }
4344 } ) )
44- . pipe ( header ( banner , { pkg : pkg } ) )
4545 . pipe ( addsrc . prepend ( [
4646 "web/jsLib/joint.min.js" ,
47- "web/jsLib/joint.shapes.uml.js" ,
4847 "web/jsLib/joint.layout.DirectedGraph.min.js"
4948 ] ) )
49+ . pipe ( stripComments ( { safe : true } ) )
50+ . pipe ( concat ( "CacheUMLExplorer.js" ) )
51+ . pipe ( gulp . dest ( "build/web/js/" ) ) ;
52+ } ) ;
53+
54+ gulp . task ( "gatherScripts" , [ "clean" , "gatherLibs" ] , function ( ) {
55+ return gulp . src ( "web/js/*.js" )
56+ . pipe ( concat ( "CacheUMLExplorer.js" ) )
57+ . pipe ( replace ( / [ ^ \s ] + \/ \* b u i l d .r e p l a c e : ( .* ) \* \/ / g, "$1" ) )
58+ . pipe ( wrap ( "CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());" ) )
59+ . pipe ( uglify ( {
60+ output : {
61+ ascii_only : true ,
62+ width : 30000 ,
63+ max_line_len : 30000
64+ }
65+ } ) )
66+ . pipe ( header ( banner , { pkg : pkg } ) )
67+ . pipe ( addsrc . prepend ( "build/web/js/CacheUMLExplorer.js" ) )
5068 . pipe ( concat ( "CacheUMLExplorer.js" ) )
5169 . pipe ( gulp . dest ( "build/web/js/" ) ) ;
5270} ) ;
@@ -90,7 +108,7 @@ gulp.task("exportCacheXML", [
90108 / \{ \{ r e p l a c e : j s } } / ,
91109 function ( ) { return fs . readFileSync ( "build/web/js/CacheUMLExplorer.js" , "utf-8" ) ; }
92110 ) )
93- . pipe ( rename ( function ( path ) { path . basename + = "-v" + pkg [ "version" ] ; } ) )
111+ . pipe ( rename ( function ( path ) { path . basename = "CacheUMLExplorer -v" + pkg [ "version" ] ; } ) )
94112 . pipe ( gulp . dest ( "build/Cache" ) ) ;
95113} ) ;
96114
0 commit comments