-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (63 loc) · 1.58 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
// Defining requirements
const gulp = require('gulp');
const sass = require('gulp-sass');
const watch = require('gulp-watch');
const run = require('gulp-run');
const concat = require('gulp-concat');
const ngrok = require('ngrok');
const browserSync = require('browser-sync').create();
const cssFiles = [
'app/assets/stylesheets/**/*.?(s)css',
'app/assets/stylesheets/*.?(s)css'
];
const jsFiles = [
'app/assets/js/*.js',
];
gulp.task('css', () => {
gulp.src(cssFiles)
.pipe(sass())
.pipe(concat('main.css'))
.pipe(gulp.dest('public/css'))
.pipe(browserSync.stream());
});
gulp.task('scripts', function() {
gulp.src(jsFiles)
.pipe(concat('all.js'))
.pipe(gulp.dest('public/js'))
.pipe(browserSync.stream());
});
gulp.task('rackup', function() {
return run('rackup').exec();
});
gulp.task('ngrok', function() {
ngrok.connect({
proto: 'http',
addr: 9292,
}, function (err, url) {
console.log('-------------------------------------');
console.log('NGROK URL: '+ url);
console.log('-------------------------------------');
gulp.start('bsync');
});
});
gulp.task('bsync', function() {
browserSync.init({
files: [
'app/assets/stylesheets/**/*.?(s)css',
'app/assets/js/*.js',
'app/views/*.haml',
'app/views/**/*.haml',
],
proxy: "localhost:9292"
});
});
gulp.task('serve', function() {
gulp.start('rackup');
gulp.start('ngrok');
gulp.start('watch');
});
gulp.task('watch', function() {
gulp.watch(cssFiles, ['css']);
gulp.watch(jsFiles, ['scripts']);
});
gulp.task('default', ['watch', 'bsync']);