-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
82 lines (71 loc) · 2 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
'use strict';
var gulp = require('gulp');
var ngrok = require('ngrok');
var browserSync = require('browser-sync').create();;
var watch = require('gulp-watch');
var newer = require('gulp-newer');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var cssmin = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var runSequence = require('run-sequence');
// paths
var sassSrc = './sass/style.scss';
var watchSass = './sass/**/*.scss';
var sassDest = './';
var fileSrc = './**/*.php';
var jsSrc = './js/**/*.js';
// more
var hostName = 'bigbang';
// Change the `hostUrl` to your local dev server ("new-site.dev" or "localhost").
var hostUrl = hostName + '.dev';
gulp.task('browser-sync', function() {
browserSync.init({
proxy: hostUrl,
socket: { domain: hostName + '.ngrok.io:80' }
},
function (err, bs) {
ngrok.connect({
addr: bs.options.get('port'),
subdomain: hostName
}, function (err, url) {})
}
);
gulp.watch([sassSrc, watchSass], ['sass', 'cssmin']);
gulp.watch([fileSrc, jsSrc]).on('change', browserSync.reload);
});
gulp.task('sass', function () {
gulp.src(sassSrc)
.pipe(sourcemaps.init())
.pipe(sass())
.on( 'error', function( err ) {
console.log( err );
this.emit( 'end' );
})
.pipe(autoprefixer('last 4 version'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(sassDest))
.pipe(browserSync.stream());
});
gulp.task('cssmin', function() {
return gulp.src('./style.css')
.pipe(cssmin())
.pipe(rename('style.min.css'))
.pipe(gulp.dest(sassDest));
});
// Run tasks without watching.
gulp.task('build', function(cb) {
runSequence('sass', 'cssmin', cb);
});
// Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch([sassSrc, watchSass], ['sass', 'cssmin']);
});
// Run Browser Sync task
gulp.task('browsersync', ['browser-sync']);
// Run default task
gulp.task('default', function(cb) {
runSequence('sass', 'cssmin', 'watch', cb);
});