This repository has been archived by the owner on Jan 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathgulpfile.js
49 lines (44 loc) · 1.77 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
ignore = require('gulp-ignore'),
insert = require('gulp-insert'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
fs = require('fs');
gulp.task('default', function(){
var APP_VER = "", APP_BLD = "";
fs.readFileSync("dist/sprestlib.js", "utf8").split('\n')
.forEach((line)=>{
if ( line.indexOf('var APP_VER') > -1 ) APP_VER = line.split('=')[1].trim().replace(/\"+|\;+/gi,'');
if ( line.indexOf('var APP_BLD') > -1 ) APP_BLD = line.split('=')[1].trim().replace(/\"+|\;+/gi,'');
});
gulp.src(['lib/promise.min.js', 'dist/sprestlib.js', 'lib/jquery.min.js', 'dist/sprestlib-ui.js'])
.pipe(concat('sprestlib-ui.bundle.js'))
.pipe(uglify())
.pipe(insert.prepend('/* SpRestLib '+APP_VER+'-'+APP_BLD+' */\n'))
.pipe(sourcemaps.init())
.pipe(ignore.exclude(["**/*.map"]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/'));
gulp.src(['dist/sprestlib.js', 'lib/jquery.min.js', 'dist/sprestlib-ui.js'])
.pipe(concat('sprestlib-ui.min.js'))
.pipe(uglify())
.pipe(insert.prepend('/* SpRestLib '+APP_VER+'-'+APP_BLD+' */\n'))
.pipe(sourcemaps.init())
.pipe(ignore.exclude(["**/*.map"]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/'));
gulp.src(['lib/promise.min.js', 'dist/sprestlib.js'])
.pipe(concat('sprestlib.bundle.js'))
.pipe(uglify())
.pipe(insert.prepend('/* SpRestLib '+APP_VER+'-'+APP_BLD+' */\n'))
.pipe(sourcemaps.init())
.pipe(ignore.exclude(["**/*.map"]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/'));
gulp.src(['dist/sprestlib.js'])
.pipe(concat('sprestlib.min.js'))
.pipe(uglify())
.pipe(insert.prepend('/* SpRestLib '+APP_VER+'-'+APP_BLD+' */\n'))
.pipe(gulp.dest('dist'));
});