-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
51 lines (42 loc) · 1.48 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
'use strict';
const browserify = require('browserify');
const gulp = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const path = require('path');
const cached = require('gulp-cached');
const remember = require('gulp-remember');
const autoprefixer = require('gulp-autoprefixer');
const sass = require('gulp-sass');
sass.compiler = require('node-sass');
const cleanCSS = require('gulp-clean-css');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const folders = {
src: './src/',
dst: './dst/'
};
gulp.task('css', function() {
return gulp.src(folders.src + 'sass/**/main.sass')
.pipe(cached('css'))
.pipe(remember('css'))
.pipe(sass({outputStyle: 'compressed', includePaths: ['node_modules']}).on('error', sass.logError))
.pipe(autoprefixer({cascade: false}))
.pipe(gulp.dest(folders.dst + 'css'));
});
gulp.task('js', function() {
return browserify(folders.src + 'js/main.js')
.transform()
.bundle()
.pipe(source('main.js'))
.pipe(buffer())
.pipe(gulp.dest(folders.dst + 'js'));
});
gulp.task('watch', function() {
gulp.watch(folders.src + 'js/**/*.js', gulp.series('js'));
gulp.watch(folders.src + 'sass/**/*.sass', gulp.series('css')).on('unlink', function(filepath) {
remember.forget('css', path.resolve(filepath));
delete cached.caches.css[path.resolve(filepath)];
});
});
gulp.task('default', gulp.series(gulp.parallel('css', 'js'), 'watch'));