-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
50 lines (40 loc) · 1.25 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
inject = require('gulp-inject'),
sourcemaps = require('gulp-sourcemaps'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
del = require('del');
/*Start browser sync*/
gulp.task('browser-sync', function() {
browserSync.init({
server: {baseDir: ['./app']}
});
gulp.watch('./app/**/*.scss', ['style']);
gulp.watch('./app/index.html').on('change', reload);
});
/*Compile CSS*/
gulp.task('style', ['clean'], function() {
return gulp.src('./app/style/scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({errLogToConsole: true}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./app/style'))
.pipe(reload({stream:true}));
});
/*Clean up build folder*/
gulp.task('clean', function() {
return del(['./app/**/*.css', '!./app/**/cssreset.css']);
});
/*Inject css links to html*/
gulp.task('inject', function() {
var target = gulp.src('./app/index.html');
return target.pipe(inject(gulp.src('./app/style/*.css', {read: false}), {relative: true}))
.pipe(gulp.dest('./app'));
});
/*Default task*/
gulp.task('default', ['style', 'inject', 'browser-sync'], function() {
});
/*Build task only*/
gulp.task('build', ['style', 'inject'], function() {
});