-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
76 lines (63 loc) · 1.78 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
"use strict";
var gulp = require('gulp'),
connect = require('connect'),
serveStatic = require('serve-static'),
connectLivereload = require('connect-livereload'),
gulpLivereload = require('gulp-livereload'),
postcss = require('gulp-postcss'),
reporter = require('postcss-reporter'),
stylelint = require('stylelint'),
cssnano = require('gulp-cssnano'),
jshint = require('gulp-jshint');
var path = {
src: 'src/',
html: 'src/**/*.html',
js: 'src/js/*.js',
postcss: 'src/postcss/**/*.css',
css: 'src/',
}
var localPort = 5000,
lrPort = 35729;
gulp.task('server', function(){
var server = connect();
server.use(connectLivereload({port: lrPort}));
server.use(serveStatic(path.src));
server.listen(localPort);
console.log("\nlocal server running at http://localhost:" + localPort + "/\n");
});
gulp.task('styles', function(){
gulp.src('src/postcss/styles.css')
.pipe(postcss([
require('precss'),
require('autoprefixer'),
require('postcss-reporter')
]))
.pipe(cssnano())
.pipe(gulp.dest(path.css))
.pipe(gulpLivereload());
});
gulp.task('stylelint', function() {
return gulp.src('src/**/*.scss')
.pipe(postcss([
stylelint({ /* options */ }),
reporter({ clearMessages: true })
]));
});
gulp.task('jshint', function(){
gulp.src(path.js)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(gulpLivereload());
});
gulp.task('html', function(){
gulp.src(path.html)
.pipe(gulpLivereload());
});
gulp.task('watch', function(){
gulp.watch(path.postcss, ['styles']);
gulp.watch(path.postcss, ['stylelint']);
gulp.watch(path.js, ['jshint']);
gulp.watch(path.html, ['html']);
gulpLivereload.listen();
});
gulp.task('default', ['server', 'watch']);