-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (57 loc) · 1.46 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
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var concat = require('gulp-concat');
/**
* Launch the Server
*/
gulp.task('browser-sync', ['sass', 'scripts'], function() {
browserSync.init({
server: "./",
port: 4726
});
});
/**
* Compile files from scss
*/
gulp.task('sass', function () {
return gulp.src('scss/styles.scss')
.pipe(sass({
includePaths: ['scss'],
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest('./'))
.pipe(browserSync.reload({stream:true}))
});
/**
* Compile files from js
*/
gulp.task('scripts', function() {
return gulp.src(['js/*.js', 'js/custom.js'])
.pipe(concat('scripts.js'))
.pipe(gulp.dest('./'))
.pipe(browserSync.reload({stream:true}))
});
/**
* Reload page when html changes
*/
gulp.task('html', function () {
browserSync.reload();
});
/**
* Watch scss files for changes & recompile
* Watch js files for changes & concatenate
* Watch html files, reload BrowserSync
*/
gulp.task('watch', function () {
gulp.watch(['scss/*.scss'], ['sass']);
gulp.watch(['js/*.js'], ['scripts']);
gulp.watch(['index.html'], ['html']);
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the scripts, launch BrowserSync & watch files.
*/
gulp.task('default', ['browser-sync', 'watch']);