forked from udacity/frontend-nanodegree-mobile-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (61 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var csso = require('gulp-csso');
// var inlineCss = require('gulp-inline-css');
var image = require('gulp-image');
var del = require('del');
var paths = {
html: 'src/**/*.html',
scripts: 'src/js/**/*.js',
styles: 'src/css/**/*.css',
images: [
// 'src/img/**/*.png',
// 'src/img/**/*.jpg',
// 'src/img/**/*.svg',
// FIXME: Gulp craps out when trying to include images from a different directory
'src/views/images/**/*.png',
'src/views/images/**/*.jpg',
'src/views/images/**/*.svg'
],
};
gulp.task('clean', function() {
return del(['dist']);
});
gulp.task('images', function() {
// return gulp.src(paths.images)
return gulp.src('src/views/images/**/*')
// Pass in options to the task
.pipe(image())
// .pipe(gulp.dest('build/img'))
.pipe(gulp.dest('dist/views/image'));
});
// Minify the JavaScript files
gulp.task('scripts', function() {
// del(['dist/js']);
return gulp.src(paths.scripts)
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
// Minify the CSS styles
gulp.task('styles', function() {
return gulp.src('src/views/css/**/*.css')
.pipe(csso())
.pipe(gulp.dest('dist/views/css'));
});
// Inline the CSS for the main index.html
// gulp.task('inline', function() {
// return gulp.src('src/index.html')
// .pipe(inlineCss())
// .pipe(gulp.dest('dist/'));
// });
gulp.task('copy', function() {
return gulp.src(paths.html)
.pipe(gulp.dest('dist'))
});
// Run the appropriate task whenever one of its files change
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.images, ['images']);
gulp.watch(paths.styles, ['styles']);
});
gulp.task('default', ['watch', 'images', 'scripts', 'styles', 'inline', 'copy']);