-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
99 lines (91 loc) · 2.09 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* Dependencies
*/
var gulp = require('gulp');
var log = require('gulp-util').log;
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var data = require('gulp-data');
var webserver = require('gulp-webserver');
var opn = require('opn');
/**
* Configurations
*/
var config = {
watch: './src/**/**',
server: {
host: 'localhost',
port: '2048',
path: '/dist'
},
html: {
src: './src/index.html',
destination: 'dist/'
},
css: {
src: './src/styles/main.scss',
destination: 'dist/css'
},
js: {
src: './src/js/**/**',
destination: 'dist/js'
}
};
/**
* Webserver up and running
*/
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
host: config.server.host,
port: config.server.port,
livereload: true,
directoryListing: false
}));
});
/**
* Open the browser
*/
gulp.task('openbrowser', function() {
opn('http://'+ config.server.host +':'+ config.server.port + config.server.path);
});
/**
* Template task (optional to change the name of the file)
*/
gulp.task('templates', function() {
gulp.src(config.html.src)
.pipe(plumber())
.pipe(rename('index.html'))
.pipe(gulp.dest(config.html.destination));
});
/**
* Stylus task (optional to change the name of the file)
*/
gulp.task('styles', function() {
gulp.src(config.css.src)
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(rename('style.css'))
.pipe(gulp.dest(config.css.destination));
});
/**
* Javascript task
*/
gulp.task('scripts', function() {
gulp.src(config.js.src)
.pipe(plumber())
.pipe(gulp.dest(config.js.destination));
});
/**
* Watch task
*/
gulp.task('watch', function() {
log('Watching files');
gulp.watch(config.watch, ['build']);
});
/**
* Command line task commands
*/
gulp.task('build', ['templates', 'styles', 'scripts']);
gulp.task('default', ['build', 'webserver', 'watch', 'openbrowser']);