-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (76 loc) · 2.1 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
var gulp = require('gulp'),
util = require('gulp-util'),
notify = require('gulp-notify'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
jade = require('gulp-jade'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
browserSync = require('browser-sync').create();
var paths = {
src : {
sass: './src/scss/main.scss',
jade: './src/jade/*.jade',
jadeWatch: './src/jade/**/*.jade',
js: './src/js/main.js',
img: './src/images/'
},
dist : {
root: './dist/',
css: './dist/css/',
markupWatch: './src/*.html',
img: './dist/images',
js: './dist/js/'
}
}
gulp.task('styles', function(){
return gulp.src(paths.src.sass)
.pipe(sourcemaps.init())
.pipe(sass().on("error", notify.onError(function (error) {
return "Error: " + error.message;
})))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.dist.css))
});
gulp.task('markup', function() {
var YOUR_LOCALS = {};
return gulp.src(paths.src.jade)
.pipe(jade({
locals: YOUR_LOCALS,
pretty: true
}))
.on("error", notify.onError(function (error) {
return "Error: " + error.message;
}))
.pipe(gulp.dest(paths.dist.root))
});
gulp.task('javascripts', function() {
gulp.src([paths.src.js])
// .pipe(browserify())
// .pipe(concat('main.js'))
.pipe(gulp.dest(paths.dist.js))
// .pipe(uglify())
// .pipe(rename('main.min.js'))
// .pipe(gulp.dest(paths.dist.js))
});
gulp.task('watch', function() {
gulp.watch(paths.src.jade ['markup']);
gulp.watch(paths.src.jadeWatch).on('change', browserSync.reload);
gulp.watch(paths.src.scss, ['sass']);
gulp.watch(paths.src.js, [ 'javascripts' ]).on('change', browserSync.reload);
gulp.watch(paths.src.images, ['images']);
gulp.watch(paths.dist.markupWatch).on('change', browserSync.reload);
})
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: paths.dist.root
}
});
});
gulp.task('default', ['markup', 'styles', 'javascripts', 'serve', 'watch']);