forked from mozbrick/brick-dialog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
129 lines (112 loc) · 3.12 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* jshint node:true */
'use strict';
var bowerDist = require('gulp-bower-dist');
var bump = require('gulp-bump');
var concat = require('gulp-concat');
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 rm = require('gulp-rm');
var stylus = require('gulp-stylus');
var vulcanize = require('gulp-vulcanize');
var paths = {
'main': 'src/brick-dialog.html',
'scripts': 'src/*.js',
'stylesheets': 'src/*.styl',
'themes': 'src/themes/**/*.styl',
'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('styles', function() {
return gulp.src(paths.stylesheets)
.pipe(stylus())
.pipe(concat('brick-dialog.css'))
.pipe(gulp.dest('src'));
});
gulp.task('themes', function() {
return gulp.src(paths.themes)
.pipe(stylus())
.pipe(gulp.dest('src/themes'));
});
gulp.task('rename', ['vulcanize'], function() {
return gulp.src('dist/brick-dialog.html')
.pipe(rename(function(path){
path.basename += '.local';
}))
.pipe(gulp.dest('dist'));
});
gulp.task('clean', ['vulcanize', 'rename'], function() {
gulp.src(['src/*.css', 'src/themes/**/*.css'])
.pipe(rm());
});
gulp.task('vulcanize', ['styles','themes'], function() {
return gulp.src('src/brick-dialog.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'));
});
// build scripts and styles
gulp.task('build', ['lint','styles','themes','vulcanize', 'rename','dist','clean']);
gulp.task('connect', function() {
connect.server({
port: 3001
});
});
gulp.task('watch', function () {
gulp.watch(paths.src, ['build']);
});
// 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',
'styles': 'Compiles main stylus',
'themes': 'Compiles themes stylus',
'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']);