-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (66 loc) · 2.13 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
var gulp = require('gulp');
var glob = require('glob');
var rjs = require('gulp-requirejs');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var less = require('gulp-less');
var replace = require("gulp-replace");
var jshint = require("gulp-jshint");
gulp.task("css", function(){
gulp.src('./assets/theme.*.less')
.pipe(sourcemaps.init())
.pipe(less({ compress:true }))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest('./deploy/assets'));
});
gulp.task('js', function(){
var views = glob.sync("views/**/*.js").map(function(value){
return value.replace(".js", "");
});
var locales = glob.sync("locales/**/*.js").map(function(value){
return value.replace(".js", "");
});
rjs({
baseUrl: './',
out: 'app.js',
insertRequire:["app"],
paths:{
"locale" : "empty:",
"text": 'libs/text'
},
deps:["app"],
include: ["libs/almond.js"].concat(views).concat(locales)
})
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest('./deploy/'));
});
gulp.task('build', ["js", "css"], function(){
var build = (new Date())*1;
return require('event-stream').merge(
//assets
gulp.src("./assets/imgs/**/*.*")
.pipe(gulp.dest("./deploy/assets/imgs/")),
//libs
gulp.src("./libs/webix/**/*.*")
.pipe(gulp.dest("./deploy/libs/webix/")),
//index
gulp.src("./index.html")
.pipe(replace('data-main="app" src="libs/require.js"', 'src="app.js"'))
.pipe(replace('<script type="text/javascript" src="libs/less.min.js"></script>', ''))
.pipe(replace(/rel\=\"stylesheet\/less\" href=\"(.*?)\.less\"/g, 'rel="stylesheet" href="$1.css"'))
.pipe(replace(/\.css\"/g, '.css?'+build+'"'))
.pipe(replace(/\.js\"/g, '.js?'+build+'"'))
.pipe(gulp.dest("./deploy/")),
//server
gulp.src("./server/**/*.*")
.pipe(gulp.dest("./deploy/server/"))
);
});
gulp.task('lint', function() {
return gulp.src('./views/**/*.js', './helpers/**/*.js', './models/**/*.js', './configs/**/*.js', './*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});