This repository has been archived by the owner on Mar 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
103 lines (89 loc) · 2.4 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
102
103
/* jshint node:true */
'use strict';
var bowerDist = require('gulp-bower-dist');
var bump = require('gulp-bump');
var connect = require('gulp-connect');
var ghpages = require('gulp-gh-pages');
var gulp = require('gulp');
var helptext = require('gulp-helptext');
var jshint = require('gulp-jshint');
var rename = require('gulp-rename');
var vulcanize = require('gulp-vulcanize');
var paths = {
'main': 'src/brick-form.html',
'scripts': 'src/*.js',
'src': 'src/*',
'dist': 'dist/**/*',
'index': 'index.html',
'bowerComponents': 'bower_components/**/*',
};
gulp.task('lint', function() {
gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('rename', ['vulcanize'], function() {
return gulp.src('dist/brick-form.html')
.pipe(rename(function(path){
path.basename += '.local';
}))
.pipe(gulp.dest('dist'));
});
gulp.task('vulcanize', function() {
return gulp.src('src/brick-form.html')
.pipe(vulcanize({
excludes: {
imports: ['bower_components'],
scripts: ['bower_components'],
styles: ['bower_components']
},
dest: 'dist',
csp: true,
inline: true
}))
.pipe(gulp.dest('dist'));
});
gulp.task('dist', ['vulcanize'], function () {
return gulp.src('dist/*.local.html')
.pipe(bowerDist())
.pipe(rename(function(path) {
path.basename = path.basename.replace('.local', '');
}))
.pipe(gulp.dest('dist'));
});
gulp.task('build', ['lint','vulcanize', 'rename','dist']);
gulp.task('connect', function() {
connect.server({
port: 3001
});
});
gulp.task('watch', function () {
gulp.watch(paths.scripts, ['lint']);
});
// do a build, start a server, watch for changes
gulp.task('server', ['build','connect','watch']);
// Bump up the Version (patch)
gulp.task('bump', function(){
gulp.src(['bower.json','package.json'])
.pipe(bump())
.pipe(gulp.dest('./'));
});
gulp.task('help', helptext({
'default': 'Shows the help message',
'help': 'This help message',
'vulcanize': 'Vulcanizes to component html file',
'lint': 'Runs JSHint on your code',
'server': 'Starts the development server',
'bump': 'Bumps up the Version',
'deploy': 'Publish to Github pages'
}));
// publish to gh pages
gulp.task('deploy', function () {
gulp.src([
paths.index,
paths.dist,
paths.bowerComponents
],{base:'./'})
.pipe(ghpages());
});
gulp.task('default', ['help']);