-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
105 lines (90 loc) · 2.87 KB
/
gulpfile.js
File metadata and controls
105 lines (90 loc) · 2.87 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var outputPath = './dist/';
var scriptsToLoad = [
'src/scripts/main.js'
];
// Load plugins
var gulp = require('gulp'),
bower = require('gulp-bower'),
compass = require('gulp-compass'),
jade = require('gulp-jade'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
del = require('del'),
webserver = require('gulp-webserver');
// Styles
gulp.task('styles', function () {
return gulp.src('src/styles/main.scss')
.pipe(compass({
sass: 'src/styles',
image: 'src/images',
css: outputPath + 'css'
}))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest(outputPath + 'css'))
.pipe(notify({message: 'Styles compiled'}));
});
// Scripts
gulp.task('scripts', function () {
return gulp.src( scriptsToLoad )
.pipe(concat('main.js'))
.pipe(gulp.dest(outputPath + 'js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(outputPath + 'js'))
.pipe(notify({message: 'Scripts compiled'}));
});
// Images
gulp.task('images', function () {
return gulp.src('src/images/**/*')
.pipe(gulp.dest(outputPath + 'img'))
.pipe(notify({message: 'Images compiled'}));
});
// Templates
gulp.task('htmlTemplates', function () {
return gulp.src('src/templates/*.html')
.pipe(gulp.dest(outputPath))
.pipe(notify({message: 'Html templates compiled'}));
});
gulp.task('jadeTemplates', function() {
gulp.src('src/templates/*.jade')
.pipe(jade())
.pipe(gulp.dest(outputPath))
.pipe(notify({message: 'Jade templates compiled'}));
});
// Webserver with auto reload
gulp.task('webserver', function() {
gulp.src( outputPath )
.pipe(webserver({
host: 'localhost',
port: '8001',
livereload: true,
directoryListing: false,
open: true
}))
.pipe(notify({message: 'Webserver is working'}));
});
// Clean
gulp.task('clean', function (cb) {
del([outputPath + 'css', outputPath + 'js', outputPath + 'img', outputPath + '*.html'], { force: true }, cb)
});
// Bower
gulp.task('bower', function() {
return bower();
});
// Default task
gulp.task('default', ['clean', 'bower'], function () {
gulp.start('styles', 'scripts', 'images', 'htmlTemplates', 'jadeTemplates');
});
// Watch
gulp.task('watch', function () {
gulp.watch('src/styles/**/*.scss', ['styles']);
gulp.watch('src/scripts/**/*.js', ['scripts']);
gulp.watch('src/images/**/*', ['images']);
gulp.watch('src/templates/*.html', ['htmlTemplates']);
gulp.watch(['src/templates/*.jade', 'src/templates/**/*.jade'], ['jadeTemplates']);
gulp.run('webserver');
});