-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
115 lines (101 loc) · 2.98 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var maps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var server = require('browser-sync').create();
function reload(done) {
server.reload();
done();
}
function serve(done) {
server.init({
server: {
baseDir: 'app'
}
});
done();
}
// compile sass to css
function css() {
return gulp.src('assets/scss/style.scss')
.pipe(maps.init())
.pipe(sass())
.pipe(maps.write('./'))
.pipe(gulp.dest('public/dist/css'))
.pipe(server.stream());
}
// concatenate js files
function scripts() {
return gulp.src([
'node_modules/jquery/dist/jquery.js',
'node_modules/bootstrap/dist/js/bootstrap.bundle.js',
'node_modules/owl.carousel/dist/owl.carousel.js',
'node_modules/magnific-popup/dist/jquery.magnific-popup.min.js',
'node_modules/swiper/dist/js/swiper.js',
'node_modules/masonry-layout/dist/masonry.pkgd.js',
'node_modules/sticky-kit/dist/sticky-kit.js',
'node_modules/headroom.js/dist/headroom.js',
'node_modules/headroom.js/dist/jQuery.headroom.js',
'node_modules/skrollr/dist/skrollr.min.js',
'node_modules/smooth-scroll/dist/smooth-scroll.js',
'node_modules/lavalamp/js/jquery.lavalamp.min.js',
'node_modules/bootstrap-select/dist/js/bootstrap-select.min.js',
'node_modules/clipboard/dist/clipboard.min.js',
'assets/js/modernizr.js',
'assets/js/app.js'
])
.pipe(maps.init())
.pipe(concat('app.js'))
.pipe(maps.write('./'))
.pipe(gulp.dest('public/dist/js'));
}
// concatenate css files
function styles() {
return gulp.src([
'node_modules/swiper/dist/css/swiper.css',
'node_modules/owl.carousel/dist/assets/owl.carousel.css',
'node_modules/magnific-popup/dist/magnific-popup.css',
'node_modules/bootstrap-select/dist/css/bootstrap-select.css',
])
.pipe(maps.init({loadMaps: true}))
.pipe(concat("vendor.css"))
.pipe(maps.write())
.pipe(gulp.dest('public/dist/css'));
}
// move fonts
function fonts() {
return gulp.src('assets/fonts/*')
.pipe(gulp.dest('public/dist/fonts'));
}
// move images
function images() {
return gulp.src('assets/images/**/*')
.pipe(gulp.dest('public/dist/images'));
}
// minify js
function minify() {
return gulp.src('public/dist/js/app.js')
.pipe(maps.init())
.pipe(uglify())
.pipe(rename('app.min.js'))
.pipe(maps.write('./'))
.pipe(gulp.dest('public/dist/js'));
}
// watch for changes
function watch() {
gulp.watch('assets/scss/**/*', css);
gulp.watch(['assets/js/*'], reload);
gulp.watch('gulpfile.js', gulp.series(scripts, styles, minify));
}
const build = gulp.series(css, scripts, styles, fonts, images, minify);
// tasks
exports.css = css;
exports.scripts = scripts;
exports.styles = styles;
exports.images = images;
exports.fonts = fonts;
exports.minify = minify;
exports.watch = watch;
exports.default = build;