forked from simogeo/Filemanager
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
92 lines (84 loc) · 2.96 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* File: gulpfile.js */
// grab our gulp packages
var gulp = require("gulp"),
gutil = require("gulp-util"),
uglify = require("gulp-uglify"),
rename = require("gulp-rename"),
extend = require("gulp-multi-extend"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
pump = require("pump"),
sourcemaps = require("gulp-sourcemaps"),
eslint = require("gulp-eslint");
// console.log("_ -> ", _);
gulp.task("browserify", function () {
"use strict";
return browserify("./app/filemanager.js")
.transform({
global: true,
minify: true,
processRelativeUrl: function(relativeUrl) {
console.log("processRelativeUrl contains -> ", relativeUrl.split("?")[0].split("#")[0]);
var DataUri = require("datauri");
var dUri = new DataUri(relativeUrl.split("?")[0].split("#")[0]);
return dUri.content;
}}, require("browserify-css"))
.bundle()
.pipe(source("filemanager.js"))
.pipe(gulp.dest("./dist"));
});
gulp.task("uglify", ["browserify"], function (callback) {
"use strict";
pump([
gulp.src("./dist/filemanager.js"),
//sourcemaps.init(),
uglify(),
rename({extname: ".min.js"}),
//sourcemaps.write(),
gulp.dest("./dist")
],
callback);
});
gulp.task("static", function () {
"use strict";
return gulp.src([
"./images/wait30trans.gif",
"./images/fileicons/**",
"./index.html",
"./themes/**"
], {base: "./"})
.pipe(gulp.dest("./dist"));
});
gulp.task("lint", function () {
"use strict";
// ESLint ignores files with "node_modules" paths.
// So, it's best to have gulp ignore the directory as well.
// Also, Be sure to return the stream from the task;
// Otherwise, the task may end before the stream has finished.
return gulp.src(["app/*.js", "!node_modules/**"])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
});
gulp.task("config", function () {
"use strict";
return gulp.src(["./app/config/*.json"])
.pipe(gulp.dest("./dist/config"));
});
gulp.task("language", function () {
"use strict";
return gulp.src(["./app/lang/*.json"])
.pipe(extend("./app/lang/en.json"))
.pipe(gulp.dest("./dist/lang"));
});
// create a default task and just log a message
gulp.task("default", ["lint", "language", "browserify", "uglify", "static", "config"], function () {
"use strict";
return gutil.log("Gulp is running!");
});