-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (35 loc) · 1.15 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
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const browserify = require('gulp-browserify');
const cleanCSS = require('gulp-clean-css');
const concat = require('gulp-concat');
const del = require('del');
function compress() {
return gulp.src('./src/css/*.css')
.pipe(concat('style.css'))
.pipe(autoprefixer({
browsers: ['last 4 versions'],
cascade: false
}))
.pipe(cleanCSS())
.pipe(gulp.dest('./dist/css'));
}
gulp.task('mainCss', compress);
function gulpJS() {
return gulp.src(['./src/js/model.js','./src/js/view.js','./src/js/controller.js','./src/js/init.js'])
.pipe(concat('bundle.js'))
.pipe(browserify({transform: ['babelify'],}))
.pipe(uglify())
.pipe(gulp.dest('./dist/js/'));
}
gulp.task('mainJs', gulpJS);
function watch() {
gulp.watch('./src/css/*.css', compress);
gulp.watch('./src/js/*.js', gulpJS);
}
function clean() {
return del([ 'dist' ]);
}
gulp.task('watch', watch,gulp.parallel( 'mainJs','mainCss'));
gulp.task('default',gulp.parallel( 'mainJs','mainCss'));