-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (86 loc) · 2.47 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
angular2 = require('gulp-angular2'),
watch = require('gulp-watch');
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./"
}
});
});
gulp.task('bs-reload', function () {
browserSync.reload();
});
gulp.task('watch-styles', function(){
return watch('src/**/*.scss', function () {
gulp.start('styles');
});
});
gulp.task('styles', function(){
return gulp.src('src/**/*.scss')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(sass())
.pipe(autoprefixer('last 2 versions'))
.pipe(gulp.dest('dist/styles/'))
.pipe(concat('main.css'))
.pipe(gulp.dest('dist/styles'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('watch-scripts', function(){
return watch('src/**/*.js', function () {
gulp.start('scripts');
});
});
gulp.task('scripts', function(){
return gulp.src('./src/main.js')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(angular2())
.pipe(gulp.dest('dist/scripts/'))
// .pipe(rename({suffix: '.min'}))
// .pipe(uglify())
// .pipe(gulp.dest('dist/scripts/'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('watch-html', function(){
return watch('./src/components/**/*.html', function () {
gulp.start('html');
});
});
gulp.task('html', function() {
return gulp.src('./src/components/**/*.html')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(rename({dirname: ''}))
.pipe(gulp.dest('dist/html/'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('watch-app', function(){
return watch('./*.html', function () {
gulp.start('bs-reload');
});
});
// gulp.task('default', ['browser-sync'], function(){
// gulp.watch("src/**/*.scss", ['styles']);
// gulp.watch("src/**/*.js", ['scripts']);
// gulp.watch("src/components/**/*.html", ['html']);
// gulp.watch("*.html", ['bs-reload']);
// });
gulp.task('default', ['browser-sync', 'html', 'styles', 'scripts', 'watch-styles', 'watch-scripts', 'watch-html', 'watch-app']);