-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (52 loc) · 2.09 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
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer');
gulp.task('copy-html', gulp.series(function(){
return gulp.src('./source/**/*.html')
.pipe(gulp.dest('./public/'))
}));
gulp.task('sass', gulp.series(function(){
var plugins = [
autoprefixer({ browsers: ['last 2 version', '> 5%'] })
];
return gulp.src('./source/sass/**/*.scss')
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.sass({
outputStyle: 'nested',
includePaths: ['./node_modules/bootstrap/scss']
}).on('error', $.sass.logError))
.pipe($.postcss(plugins))
// .pipe($.if(options.env === 'production', $.cleanCss()))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('./public/stylesheet'))
// .pipe(browserSync.stream());
}));
gulp.task('babel', gulp.series(function(){
return gulp.src('./source/javascript/**/*.js')
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.babel({
presets: ['@babel/env']
}))
.pipe($.concat('main.js'))
// .pipe($.if(options.env === 'production', $.uglify()))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('./public/javascript'))
// .pipe(browserSync.stream());
}));
gulp.task('copy-images', gulp.series(function(){
return gulp.src(['./source/images/**/*.png', './source/images/**/*.jpg', './source/images/**/*.svg'])
.pipe(gulp.dest('./public/images'))
}));
gulp.task('watch', gulp.series(function () {
gulp.watch('./source/**/*.html', gulp.series('copy-html'));
gulp.watch('./source/sass/**/*.scss', gulp.series('sass'));
gulp.watch('./source/javascript/**/*.js', gulp.series('babel'));
}));
gulp.task('stream', gulp.series(function () {
$.watch('./source/**/*.html', gulp.series('copy-html'));
$.watch('./source/sass/**/*.scss', gulp.series('sass'));
$.watch('./source/javascript/**/*.js', gulp.series('babel'));
}));
gulp.task('default', gulp.series(['copy-html', 'sass', 'babel', 'copy-images', 'watch', 'stream']));