This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
71 lines (63 loc) · 2.14 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
64
65
66
67
68
69
70
71
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const babel = require('gulp-babel');
const cleanCSS = require('gulp-clean-css');
const minify = require('gulp-minify');
const rename = require("gulp-rename");
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const uglify = require('gulp-uglify');
const browserify = require('browserify');
const babelify = require('babelify');
// const sourcemaps = require('gulp-sourcemaps');
gulp.task('css', () =>
gulp.src('src/styles/main.css')
.pipe(autoprefixer({cascade: false}))
.pipe(cleanCSS())
.pipe(rename((path) => {
path.basename = "main.min";
}))
.pipe(gulp.dest('dist/styles/'))
);
gulp.task('js', () =>
gulp.src('src/scripts/script.js')
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(uglify())
.pipe(rename((path) => {
path.basename = "script.min";
}))
.pipe(gulp.dest('dist/scripts/'))
);
gulp.task('libs', () =>
browserify({entries: 'src/scripts/libs.js', debug: true})
.transform("babelify", { presets: ["@babel/preset-env"] })
.bundle()
.pipe(source('libs.js'))
.pipe(buffer())
// .pipe(sourcemaps.init())
.pipe(uglify())
// .pipe(sourcemaps.write('./maps'))
.pipe(rename((path) => {
path.basename = "libs.min";
}))
.pipe(gulp.dest('dist/scripts/'))
);
gulp.task('html', () =>
gulp.src(['src/*.html'])
.pipe(gulp.dest('dist/'))
);
gulp.task('static', () =>
gulp.src(['static/**/*', 'static/**/.*', 'static/.**/*', 'static/.**/.*'], {base: 'static'})
.pipe(gulp.dest('dist'))
);
gulp.task('assets', () =>
gulp.src(['src/assets/**/*'], {base: 'src/assets'})
.pipe(gulp.dest('dist'))
);
gulp.task('watch', () => {
gulp.watch('src/styles/main.css', gulp.series('css'));
gulp.watch('src/scripts/script.js', gulp.series('js'));
gulp.watch('src/*.html', gulp.series('html'));
});
gulp.task('default', gulp.parallel('css','js','libs','html','static','assets'));
gulp.task('build', gulp.parallel('css','js','libs','html','static','assets'));