-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
80 lines (67 loc) · 1.9 KB
/
Copy pathgulpfile.js
File metadata and controls
80 lines (67 loc) · 1.9 KB
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
'use strict';
const gulp = require('gulp'),
jshint = require('gulp-jshint'),
nodemon = require("gulp-nodemon"),
browserSync = require("browser-sync").create(),
sass = require('gulp-sass'),
babel = require("gulp-babel"),
uglify = require("gulp-uglify");
// Load plugins ??? load.plumber()???
const load = require('gulp-load-plugins')();
let reload = browserSync.reload;
var path = {
js: 'public/es6js/*.js',
scss: 'public/sass/*.sass'
}
/* es6 */
gulp.task('es6', () =>
gulp.src(path.js)
.pipe(babel({
presets: ['es2015']
}))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts/'))
);
/*lint*/
gulp.task('lint', () =>
gulp.src(path.js)
.pipe(jshint())
.pipe(jshint.reporter('default'))
);
//https://segmentfault.com/a/1190000003787713
gulp.task('serve', ['nodemon'], function () {
var files = [
'view/*.hbs',
'public/**/*.css',
];
browserSync.init(files, {
proxy: 'http://localhost:3000',
files: [path.js, path.scss],
browser: "firefox",
open: false, //don't oepn browser
port: 7000,
});
//gulp.watch(path.scss, ['sass']).on("change", reload);
gulp.watch('public/stylesheets/*.css').on("change", reload);
gulp.watch(path.js, ['lint', 'es6']).on("change", reload);
});
gulp.task('sass', function () {
return gulp.src(path.scss)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('public/stylesheets'))
.pipe(reload({stream: true}));
});
gulp.task('nodemon', function (cb) {
var started = false;
return nodemon({
script: './bin/www' //local server entrance
}).on('start', function () {
// to avoid nodemon being started multiple times
// thanks @matthisk
if (!started) {
cb();
started = true;
}
});
});
gulp.task('default', ['serve']);