-
Notifications
You must be signed in to change notification settings - Fork 116
/
gulpfile.js
executable file
·63 lines (55 loc) · 1.46 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
61
62
63
const gulp = require('gulp');
// const { parallel } = require('gulp');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const babel = require('gulp-babel');
const replace = require('gulp-replace');
const concatCss = require('gulp-concat-css');
const cleanCSS = require('gulp-clean-css');
gulp.task('uglify-css', done => {
gulp.src('src/**/01-css-task/solution/style.css')
.pipe(concatCss("style.min.css"))
.pipe(cleanCSS({
level: 2,
}))
.pipe(gulp.dest('src/styles'));
done();
})
gulp.task('copy-html', done => {
gulp.src('src/**/02-js-task/index.html')
.pipe(replace('./solution/index.js', './index.js'))
.pipe(rename( path => {
return {
dirname: path.dirname.replace('02-js-task', 'example'),
basename: path.basename,
extname: '.html'
};
}))
.pipe(gulp.dest(file => {
return file.base;
}));
done();
});
gulp.task('uglify-js', done => {
gulp.src('src/**/02-js-task/solution/index.js')
.pipe(babel({
presets: [
['@babel/preset-env', {
modules: false,
}]
]
}))
.pipe(uglify())
.pipe(rename( path => {
return {
dirname: path.dirname.replace('02-js-task/solution', 'example'),
basename: path.basename,
extname: '.js'
};
}))
.pipe(gulp.dest(file => {
return file.base;
}));
done();
});
exports.build = gulp.parallel(['uglify-css', 'uglify-js', 'copy-html']);