-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
112 lines (94 loc) · 4.54 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* ------------------------------------------------------------------------------
*
* # Gulp file
*
* Basic Gulp tasks for Limitless template
*
* Version: 1.1
* Latest update: Aug 20, 2016
*
* ---------------------------------------------------------------------------- */
// Include gulp
var gulp = require('gulp');
// Include our plugins
var jshint = require('gulp-jshint');
var less = require('gulp-less');
var minifyCss = require('gulp-clean-css');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
// Lint task
gulp.task('lint', function() {
return gulp
.src('assets/js/core/app.js') // lint core JS file. Or specify another path
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Compile less files of a full version
gulp.task('less_full', function() {
return gulp
.src('assets/less/_main_full/*.less') // locate /less/ folder root to grab 4 main files
.pipe(less()) // compile
.pipe(gulp.dest('assets/css')) // destination path for normal CSS
.pipe(minifyCss({ // minify CSS
keepSpecialComments: 0 // remove all comments
}))
.pipe(rename({ // rename file
suffix: ".min" // add *.min suffix
}))
.pipe(gulp.dest('assets/css')); // destination path for minified CSS
});
// Compile less files of starter kit
gulp.task('less_starters', function() {
return gulp
.src('assets/less/_main_starters/*.less') // locate /less/ folder root to grab 4 main files
.pipe(less()) // compile
.pipe(gulp.dest('starters/assets/css')) // destination path for normal CSS
.pipe(minifyCss({ // minify CSS
keepSpecialComments: 0 // remove all comments
}))
.pipe(rename({ // rename file
suffix: ".min" // add *.min suffix
}))
.pipe(gulp.dest('starters/assets/css')); // destination path for minified CSS
});
// Concatenate & minify JS (uncomment if you want to use)
/*gulp.task('concatenate', function() {
return gulp
.src('assets/js/*.js') // path to js files you want to concat
.pipe(concat('all.js')) // output file name
.pipe(gulp.dest('assets/js')) // destination path for normal JS
.pipe(rename({ // rename file
suffix: ".min" // add *.min suffix
}))
.pipe(uglify()) // compress JS
.pipe(gulp.dest('assets/js')); // destination path for minified JS
});*/
// Minify template's core JS file
gulp.task('minify_core', function() {
return gulp
.src('assets/js/core/app.js') // path to app.js file
.pipe(uglify()) // compress JS
.pipe(rename({ // rename file
suffix: ".min" // add *.min suffix
}))
.pipe(gulp.dest('assets/js/core/')); // destination path for minified file
});
// Watch files for changes
gulp.task('watch', function() {
gulp.watch('assets/js/core/app.js', [ // listen for changes in app.js file and automatically compress
'lint', // lint
//'concatenate', // concatenate & minify JS files (uncomment if in use)
'minify_core' // compress app.js
]);
gulp.watch('assets/less/**/*.less', ['less_full', 'less_starters']); // listen for changes in all LESS files and automatically re-compile
});
// Default task
gulp.task('default', [ // list of default tasks
'lint', // lint
'less_full', // full version less compile
'less_starters', // starter kit less compile
//'concatenate', // uncomment if in use
'minify_core', // compress app.js
'watch' // watch for changes
]);