-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (54 loc) · 1.57 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
const path = require('path');
const gulp = require('gulp');
const less = require('gulp-less');
const concat = require('gulp-concat');
const minify = require('gulp-minify');
gulp.task('less', () => {
var normal = gulp
.src('./src/less/**/_main.less') // Get main file
.pipe(concat('nitpum-navbar.css')) // Combine into single file
.pipe(less())
.pipe(gulp.dest('./dist/css/'))
var minify = gulp
.src('./src/less/**/_main.less') // Get main file
.pipe(concat('nitpum-navbar.min.css')) // Combine into single file
.pipe(less({
compress : true // Simply minify code
}))
.pipe(gulp.dest('./dist/css/'))
return [normal, minify];
});
gulp.task('js', function () {
gulp.src('./src/js/**/_main.js')
.pipe(concat('nitpum-navbar.js'))
.pipe(minify({
ext: {
src: '.js',
min: '.min.js',
},
/*
output: {
preserveComments: 'some'
} */
}))
.pipe(gulp.dest('./dist/js/'));
})
gulp.task('compile', ['less']);
// Watch and auto compile
gulp.task('autocompile', function () {
gulp.watch('./src/less/**/*.less', ['less']);
gulp.watch('./src/js/**/*.js', ['js']);
});
//
// Automation
//
function getPackageJsonVersion() {
// We parse the json file instead of using require because require caches
// multiple calls so the version number won't be updated
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
};
gulp.task('bump-version', function () {
return gulp.src(['./package.json'])
.pipe(bump({ type: 'minor' }))
.pipe(gulp.dest('./'))
});