-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (58 loc) · 1.67 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
"use strict";
// Plugins
var gulp = require( 'gulp' ),
connect = require( 'connect' ),
connectLivereload = require( 'connect-livereload' ),
gulpLivereload = require( 'gulp-livereload' ),
sass = require( 'gulp-sass' ),
prefix = require( 'gulp-autoprefixer' ),
jshint = require( "gulp-jshint" ),
stylish = require( 'jshint-stylish' );
// paths & files
var path = {
src: 'src/',
html: 'src/**/*.html',
js: 'src/js/*.js',
sass: 'sass/**/*.scss',
css: 'src/css/',
};
// ports
var localPort = 4000,
lrPort = 35729;
// start local server
gulp.task( 'server', function() {
var server = connect();
server.use( connectLivereload( { port: lrPort } ) );
server.use( connect.static( path.src ) );
server.listen( localPort );
console.log( "\nlocal server running at http://localhost:" + localPort + "/\n" );
});
// jshint
gulp.task( 'jshint', function() {
gulp.src( path.js )
.pipe( jshint() )
.pipe( jshint.reporter( stylish ) );
});
// compile sass
gulp.task( 'sass', function() {
gulp.src( path.sass )
.pipe( sass({
outputStyle: [ 'expanded' ],
sourceComments: 'normal',
errLogToConsole: true
}))
.pipe( prefix() )
.pipe( gulp.dest( path.css ) );
});
// watch file
gulp.task( 'watch', function(done) {
var lrServer = gulpLivereload();
gulp.watch( [ path.html, path.js, path.css + '/**/*.css' ] )
.on( 'change', function( file ) {
lrServer.changed( file.path );
});
gulp.watch( path.js, ['jshint'] );
gulp.watch( path.sass, ['sass'] );
});
// default task
gulp.task( 'default', [ 'server', 'watch' ] );