forked from kleinejan/titatoggle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
98 lines (86 loc) · 2.69 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
var gulp = require('gulp'),
less = require('gulp-less'),
autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
cssmin = require('gulp-cssmin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
fileinclude = require('gulp-file-include'),
runSequence = require('run-sequence'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
highlight = require('gulp-highlight');
path = require('path');
del = require('del');
gulp.task('fileinclude', function () {
gulp.src(['index.html'])
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(highlight())
.pipe(gulp.dest('./docs'));
});
gulp.task('less:main', function () {
return gulp.src('./less/main.less')
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')]
})).pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('./docs/css'))
.pipe(browserSync.stream());
});
gulp.task('less:slider', function () {
return gulp.src('./less/titatoggle.less')
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')]
})).pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(rename({suffix: '-dist'}))
.pipe(gulp.dest('./dist'));
});
gulp.task('less:slider-min', function () {
return gulp.src('./less/titatoggle.less')
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')]
})).pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
})).pipe(cssmin())
.pipe(rename({suffix: '-dist-min'}))
.pipe(gulp.dest('./dist'));
});
gulp.task('copy:src', function () {
return gulp.src('./less/_titatoggle.less')
.pipe(rename({basename: "titatoggle",}))
.pipe(gulp.dest('./dist'));
});
gulp.task('copy:js', function () {
return gulp.src('node_modules/highlight.js/lib/**/*.*')
.pipe(gulp.dest('./docs/js'));
});
gulp.task('browser-sync', function () {
browserSync.init({
injectChanges: true,
server: {
baseDir: "./docs"
}
});
gulp.watch("less/**/*.*", ['less']);
gulp.watch("_includes/**/*.*", ['fileinclude']);
gulp.watch("docs/**/*.*").on("change", reload);
});
gulp.task('less', function (callback) {
runSequence(['less:main', 'less:slider', 'less:slider-min'],
callback
)
});
gulp.task('default', function (callback) {
runSequence(['copy:js', 'copy:src', 'less', 'fileinclude'], 'browser-sync',
callback
)
});