-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (51 loc) · 1.48 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
var gulp = require('gulp');
var less = require('gulp-less');
var path = require('path');
var inject = require('gulp-inject');
var autoprefixer = require('gulp-autoprefixer');
var webserver = require('gulp-webserver');
var runSequence = require('run-sequence');
var appBaseUrl = 'http://localhost:8000/example/index.html';
gulp.task('copy', function() {
gulp.src(['./src/fonts/**/*']).pipe(gulp.dest('dist/fonts'));
});
gulp.task('less', function() {
return gulp
.src('./src/less/**/[^_]*.less')
.pipe(
less({
paths: [path.join(__dirname, 'less', 'includes')]
})
)
.pipe(autoprefixer())
.pipe(gulp.dest('./dist/css'));
});
gulp.task('less:watch', function() {
gulp.watch('./src/less/**/*.less', ['less']);
});
gulp.task('inject', function() {
var target = gulp.src('./example/index.html');
// It's not necessary to read the files (will speed up things), we're only after their paths:
var sources = gulp.src(['./dist/**/*.css', './dist/**/*.js'], {
read: false
});
return target.pipe(inject(sources)).pipe(gulp.dest('./example'));
});
gulp.task('webserver', function() {
gulp.src('.').pipe(
webserver({
livereload: true,
directoryListing: true,
open: appBaseUrl
})
);
});
gulp.task('default', function() {
runSequence('serve');
});
gulp.task('serve', function() {
runSequence('copy', 'less', 'inject', 'webserver', 'less:watch');
});
gulp.task('prod', function() {
runSequence('copy', 'less', 'inject');
});