-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (67 loc) · 1.85 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
'use strict';
// Require
var gulp = require('gulp');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-clean-css');
var concat = require('gulp-concat');
var eslint = require('gulp-eslint');
var del = require('del');
var path = require('path');
// Vars
var src = 'src/';
var dst = 'dist/';
var tplPath = 'src/templates'; //must be same as fileManagerConfig.tplPath
var jsFile = 'angular-filemanager.min.js';
var cssFile = 'angular-filemanager.min.css';
gulp.task('clean', function (cb) {
del(dst + '/*', cb);
});
gulp.task('cache-templates', function () {
return gulp.src(tplPath + '/*.html')
.pipe(templateCache(jsFile, {
module: 'FileManagerApp',
base: function(file) {
return tplPath + '/' + path.basename(file.history[0]);
}
}))
.pipe(gulp.dest(dst));
});
gulp.task('concat-uglify-js', ['cache-templates'], function() {
return gulp.src([
src + 'js/app.js',
src + 'js/*/*.js',
dst + '/' + jsFile
])
.pipe(concat(jsFile))
.pipe(uglify())
.pipe(gulp.dest(dst));
});
gulp.task('minify-css', function() {
return gulp.src(src + 'css/*.css')
.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(concat(cssFile))
.pipe(gulp.dest(dst));
});
gulp.task('lint', function () {
return gulp.src([src + 'js/app.js', src + 'js/*/*.js'])
.pipe(eslint({
'rules': {
'quotes': [2, 'single'],
//'linebreak-style': [2, 'unix'],
'semi': [2, 'always']
},
'env': {
'browser': true
},
'globals': {
'angular': true,
'jQuery': true
},
'extends': 'eslint:recommended'
}))
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('default', ['concat-uglify-js', 'minify-css']);
gulp.task('build', ['clean', 'lint', 'default']);