-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (50 loc) · 1.59 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
'use strict';
var fs = require('fs');
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var minify = require('gulp-minify');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var path = {
scss: './scss/style.scss',
css: './css'
};
// scss
gulp.task('scss', function () {
return gulp.src(path.scss)
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(path.css))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(path.css));
});
gulp.task('scss-minify', function () {
return gulp.src(path.scss)
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(path.css));
});
// concat
gulp.task('concat_js', function() {
// get file index
var includes = JSON.parse(fs.readFileSync('./js/index.json')).includes;
//An array of files is required for the correct order of contact
return gulp.src(includes) //file array need for
.pipe(concat('./scripts.js'))
.pipe(gulp.dest('./js/'))
.pipe(minify({
ext:{
src:'',
min:'.min.js'
},
noSource: true}))
.pipe(gulp.dest('./js/'));
});
// watch
gulp.task('watch', function () {
gulp.watch('./js/partials/**/*.js', gulp.series('concat_js'));
gulp.watch('./js/index.json', gulp.series('concat_js'));
gulp.watch('./scss/**/*.scss', gulp.series('scss', 'scss-minify'));
});
gulp.task('default', gulp.series('watch', 'concat_js', 'scss', 'scss-minify'));