-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (53 loc) · 1.57 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
'use strict';
const gulp = require('gulp');
const sass = require('gulp-sass');
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const pump = require('pump');
const jsLib = ['./assets/js/smooth-scroll.min.js'];
gulp.task('sass', function () {
return gulp.src('./assets/scss/main.scss')
.pipe(sass({
includePaths: require('node-normalize-scss').includePaths
}).on('error', sass.logError))
.pipe(sourcemaps.init())
.pipe(rename('styles.css'))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('watch', function () {
gulp.start('copy-js-lib');
gulp.start('js-compile');
gulp.start('copy-imgs');
gulp.watch('./assets/scss/**/*.scss', ['sass']);
gulp.watch('./assets/js/*.js', ['copy-js-lib', 'js-compile']);
});
gulp.task('sass:prod', function () {
return gulp.src('./assets/scss/main.scss')
.pipe(sass({
includePaths: require('node-normalize-scss').includePaths
}))
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename('styles.css'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('copy-imgs', function() {
return gulp.src('./assets/img/*.png')
.pipe(gulp.dest('./dist/img'));
});
gulp.task('copy-js-lib', function() {
return gulp.src(jsLib)
.pipe(gulp.dest('./dist/js'));
});
gulp.task('js-compile', function(cb) {
pump([
gulp.src('./assets/js/main.js'),
babel({
presets: ['env']
}),
uglify(),
gulp.dest('./dist/js')
], cb);
});