-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
70 lines (57 loc) · 1.8 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
/*global require, autoprefixer, __dirname */
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
copy = require('gulp-contrib-copy');
gulp.task('express', function() {
var express = require('express');
var app = express();
app.use(require('connect-livereload')({port: 35729}));
app.use(express.static(__dirname));
app.listen(4000, '0.0.0.0');
});
var tinylr;
gulp.task('livereload', function() {
tinylr = require('tiny-lr')();
tinylr.listen(35729);
});
function notifyLiveReload(event) {
var fileName = require('path').relative(__dirname, event.path);
tinylr.changed({
body: {
files: [fileName]
}
});
}
gulp.task('styles', function() {
return sass('sass', { style: 'expanded' })
.pipe(gulp.dest('css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('css'));
});
gulp.task('watch', function() {
gulp.watch('sass/*.scss', ['styles']);
gulp.watch('*.html', notifyLiveReload);
gulp.watch('css/*.css', notifyLiveReload);
gulp.watch('src/**/*.js', notifyLiveReload);
});
gulp.task('javascript', function() {
return gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(concat('angular-pdf-make.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
gulp.task('copy', function() {
gulp.src('src/angular-pdf-make.tpl.html')
.pipe(copy())
.pipe(gulp.dest('dist/'));
});
gulp.task('default', ['styles', 'express', 'livereload', 'watch'], function() {
});
gulp.task('release', ['javascript', 'copy']);