-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (53 loc) · 1.77 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
cssnano = require('gulp-cssnano'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
cache = require('gulp-cache'),
notify = require('gulp-notify'),
livereload = require('gulp-livereload'),
del = require('del');
var basepath = 'public';
var styles = ['src/app/scss/style.scss', 'src/pages/**/*.scss'];
gulp.task('sass', function () {
return gulp.src(styles)
.pipe(concat('bundle.scss'))
.pipe(sass().on('error', function() {
notify({ message: 'Sass failed to compile'})
}))
.pipe(gulp.dest(basepath + '/bin/css'))
.pipe(rename({suffix: '.min'}))
.pipe(cssnano())
.pipe(gulp.dest(basepath + '/bin/css'))
.pipe(notify({ message: 'Sass task complete' }))
.pipe(livereload());
});
var javascripts = ['src/app/js/app.js', 'src/app/js/services/*.js', 'src/pages/**/*.js'];
gulp.task('scripts', function() {
return gulp.src(javascripts)
.pipe(concat('bundle.js'))
.pipe(gulp.dest(basepath + '/bin/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(basepath + '/bin/js'))
.pipe(notify({ message: 'Scripts task complete' }))
.pipe(livereload());
});
var htmls = ['src/*.html', 'src/pages/**/*.html'];
gulp.task('copyHtml', function() {
return gulp.src(htmls)
.pipe(gulp.dest(basepath))
.pipe(livereload());
});
gulp.task('watch', function() {
livereload.listen({ basePath: basepath });
gulp.watch(styles, ['sass']);
gulp.watch(javascripts, ['scripts'])
gulp.watch(htmls, ['copyHtml']);
});
gulp.task('server', function(done) {
http.createServer(
st({ path: __dirname + '/' + basepath, index: 'index.html', cache: false })
).listen(8080, done);
});