-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (61 loc) · 1.82 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
72
73
74
75
'user strict';
const gulp = require('gulp');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const sourcemaps = require('gulp-sourcemaps');
const debug = require('gulp-debug');
const uglify = require('gulp-uglify');
const newer = require('gulp-newer');
const del = require('del');
gulp.task('clean', function() {
// console.log("clean public");
return del(['public']);
})
gulp.task('lib', function() {
return gulp.src([
'source/libs/angular.min.js',
'source/libs/*.js'])
.pipe(debug({title: 'src'}))
.pipe(concat("lib.js"))
.pipe(debug({title: 'concat'}))
.pipe(uglify())
.pipe(debug({title: 'uglify'}))
.pipe(gulp.dest('public/lib'));
})
gulp.task('js', function() {
return gulp.src([
'!source/libs/*.js',
'source/**/*.module.js',
'source/**/*.js'
])
// .pipe(debug({title: 'src'}))
.pipe(babel())
.pipe(debug({title: 'babel'}))
.pipe(concat("script.js"))
.pipe(debug({title: 'concat'}))
.pipe(uglify(/*{ mangle: false }*/))
.pipe(debug({title: 'uglify'}))
.pipe(gulp.dest('public/js'));
})
gulp.task('html', function() {
return gulp.src('source/**/*.html' /*, {since : gulp.lastRun('html')}*/)
.pipe(newer('public')) //Только обновленные файлы
.pipe(debug({title: 'src'}))
.pipe(gulp.dest('public'));
})
gulp.task('css', function() {
console.log('task css');
return gulp.src('source/**/*.css')
.pipe(sourcemaps.init())
.pipe(debug({title: 'src'}))
.pipe(concat("style.css"))
.pipe(debug({title: 'concat'}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('public/css'));
})
gulp.task('build', ['lib', 'html', 'css', 'js'], function() {
gulp.watch('source/lib/*.js', ['lib']);
gulp.watch('source/**/*.html', ['html']);
gulp.watch('source/css/*.css', ['css']);
gulp.watch('source/**/*.js', ['js']);
});