-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (48 loc) · 1.61 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
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const { src, series, parallel, dest, watch } = require('gulp');
const concat = require('gulp-concat');
const terser = require('gulp-terser');
const postcss = require('gulp-postcss');
const cssnano = require('cssnano');
const autoprefixer = require('autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
let jsPaths = 'assets/js/*.js';
let datajsPaths = 'assets/data/*.js';
let cssPath = 'assets/css/**/*.css'
function copyHtml() {
return src('*.html').pipe(gulp.dest('build'));
}
function imgTask() {
return src('assets/img/*').pipe(imagemin()).pipe(gulp.dest('build/assets/img'));
}
function jsTask() {
return src(jsPaths)
.pipe(sourcemaps.init())
.pipe(concat('bundle.js'))
.pipe(terser())
.pipe(sourcemaps.write('.'))
.pipe(dest('build/assets/js'));
}
function datajsTask(){
return src(jsPaths)
.pipe(sourcemaps.init())
.pipe(concat('data.js'))
.pipe(terser())
.pipe(sourcemaps.write('.'))
.pipe(dest('build/assets/js'));
}
function cssTask() {
return src(cssPath)
.pipe(sourcemaps.init())
.pipe(concat('style.css'))
.pipe(postcss([autoprefixer(), cssnano()])) //not all plugins work with postcss only the ones mentioned in their documentation
.pipe(sourcemaps.write('.'))
.pipe(dest('build/assets/css'));
}
exports.copyHtml = copyHtml;
exports.imgTask = imgTask;
exports.jsTask = jsTask;
exports.cssTask = cssTask;
exports.datajsTask = datajsTask;
exports.default = parallel(copyHtml,imgTask,datajsTask,jsTask,cssTask);