-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
101 lines (91 loc) · 2.76 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
100
101
var _ = require('lodash');
var babel = require('gulp-babel');
var cleanCSS = require('gulp-clean-css');
var ghPages = require('gulp-gh-pages');
var gulp = require('gulp');
var gutil = require('gulp-util');
var nodemon = require('gulp-nodemon');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var rimraf = require('rimraf');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
gulp.task('default', ['serve']);
gulp.task('build', ['js', 'css']);
gulp.task('serve', ['build'], function() {
var monitor = nodemon({
script: './demo/server.js',
ext: 'js css',
ignore: ['**/*.js', '**/.css'], // Ignore everything else as its watched seperately
})
.on('start', function() {
console.log('Server started');
})
.on('restart', function() {
console.log('Server restarted');
});
watch(['./index.js', 'demo/**/*.js', 'src/**/*.js'], function() {
console.log('Rebuild client-side JS files...');
gulp.start('js');
});
watch(['demo/**/*.css', 'src/**/*.css'], function() {
console.log('Rebuild client-side CSS files...');
gulp.start('css');
});
});
gulp.task('js', ()=>
gulp.src('./src/angular-ui-scribble.js')
.pipe(plumber({
errorHandler: function(err) {
gutil.log(gutil.colors.red('ERROR DURING JS BUILD'));
process.stdout.write(err.stack);
this.emit('end');
},
}))
.pipe(rename('angular-ui-scribble.js'))
.pipe(babel({
presets: ['es2015'],
plugins: ['angularjs-annotate'],
}))
.pipe(gulp.dest('./dist'))
.pipe(uglify())
.pipe(rename('angular-ui-scribble.min.js'))
.pipe(gulp.dest('./dist'))
);
gulp.task('css', ()=>
gulp.src('./src/angular-ui-scribble.css')
.pipe(rename('angular-ui-scribble.css'))
.pipe(gulp.dest('./dist'))
.pipe(rename('angular-ui-scribble.min.css'))
.pipe(cleanCSS())
.pipe(gulp.dest('./dist'))
);
gulp.task('gh-pages', ['build'], function() {
rimraf.sync('./gh-pages');
return gulp.src([
'./LICENSE',
'./demo/_config.yml',
'./demo/app.js',
'./demo/index.html',
'./demo/style.css',
'./dist/**/*',
'./node_modules/angular/angular.min.js',
'./node_modules/bootstrap/dist/css/bootstrap.min.css',
'./node_modules/bootstrap/dist/js/bootstrap.min.js',
'./node_modules/font-awesome/css/font-awesome.min.css',
'./node_modules/font-awesome/fonts/fontawesome-webfont.ttf',
'./node_modules/font-awesome/fonts/fontawesome-webfont.woff',
'./node_modules/font-awesome/fonts/fontawesome-webfont.woff2',
'./node_modules/signature_pad/dist/signature_pad.min.js',
], {base: __dirname})
.pipe(rename(function(path) {
if (path.dirname == 'demo') { // Move all demo files into root
path.dirname = '.';
}
return path;
}))
.pipe(ghPages({
cacheDir: 'gh-pages',
push: true, // Change to false for dryrun (files dumped to cacheDir)
}))
});