-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (69 loc) · 1.84 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
'use strict';
// packages
var gulp = require('gulp');
var del = require('del');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cleancss = require('gulp-clean-css');
var uglify = require('gulp-uglify');
// project vars
const build = {dir:'./build'};
const src = {
sass:{files:'./src/sass/**/*.scss'},
font:{files:'./node_modules/typeface-palanquin/files/*'},
html:{files:'./src/**/*.html'},
js:{files:'./src/js/**/*.js'},
lib:{files:'./node_modules/particles.js/particles.js'}
};
// build sass
gulp.task('sass', function() {
return gulp.src(src.sass.files)
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer("last 3 version"))
.pipe(cleancss())
.pipe(gulp.dest(build.dir + '/css'));
});
// watch sass
gulp.task('sass:watch', function() {
gulp.watch(src.sass.files, ['sass']);
});
// copy fonts
gulp.task('font:copy', function() {
return gulp.src(src.font.files)
.pipe(gulp.dest(build.dir + '/css/fonts'));
});
// copy html
gulp.task('html:copy', function() {
return gulp.src(src.html.files)
.pipe(gulp.dest(build.dir));
});
// watch html
gulp.task('html:watch', function() {
gulp.watch(src.html.files, ['html:copy']);
});
// copy js
gulp.task('js:minify', function() {
gulp.src(src.js.files)
.pipe(uglify())
.pipe(gulp.dest(build.dir + '/js'));
});
// watch js
gulp.task('js:watch', function() {
gulp.watch(src.js.files, ['js:minify']);
});
// copy libs
gulp.task('lib:minify', function() {
return gulp.src(src.lib.files)
.pipe(uglify())
.pipe(gulp.dest(build.dir + '/js/libs'));
});
// clean
gulp.task('clean', function() {
return del([build.dir]);
});
// build
gulp.task('build', ['sass', 'js:minify', 'lib:minify', 'font:copy', 'html:copy']);
// watch
gulp.task('watch', ['sass:watch', 'js:watch', 'html:watch']);
// default task
gulp.task('default', ['build']);