-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
95 lines (79 loc) · 2.03 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import gulpLoadPlugins from 'gulp-load-plugins';
import browserSync from 'browser-sync';
import del from 'del';
import jspm from 'jspm';
import pkg from './package.json';
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
gulp.task('jspm', ['eslint'], (cb) => {
const builder = new jspm.Builder();
builder.buildStatic(
'js/head',
'js/dist/headBundle.js',
{
minify: false,
format: 'global',
globalName: 'Achbar',
sourceMaps: true,
}
).then(
builder.buildStatic(
'js/head',
'js/dist/headBundle.min.js',
{
minify: true,
format: 'global',
globalName: 'Achbar',
sourceMaps: true,
}
)
).then(() => {
cb();
}).catch((err) => {
console.log(err); // eslint-disable-line no-console
cb();
});
});
gulp.task('jspm:watch', () => {
gulp.watch('js/body/**/*', ['jspm:body']);
});
function eslint(files, options) {
return () => gulp.src(files)
.pipe(reload({ stream: true, once: true }))
.pipe($.eslint(options))
.pipe($.eslint.format())
.pipe($.if(!browserSync.active, $.eslint.failAfterError()));
}
gulp.task('eslint', eslint(['**/*.js']));
gulp.task('jsdoc', $.shell.task([
'node_modules/.bin/jsdoc --verbose -c jsdoc.conf.json',
]));
// Push documentation to github
gulp.task('gh-pages', $.shell.task([
'git push origin --delete gh-pages',
`git subtree push --prefix docs/htz-collapsibles/${pkg.version} origin gh-pages`,
]));
gulp.task('cleanDocs', del.bind(null, ['docs']));
gulp.task('serve', () => {
browserSync({
notify: true,
port: 9001,
server: {
baseDir: './',
},
});
gulp.watch(['src/**/*.js', 'test.js', 'index.html'], ['eslint']).on('change', reload);
});
gulp.task('serve:docs', () => {
browserSync({
notify: true,
port: 9002,
server: {
baseDir: `./docs/htz-collapsibles/${pkg.version}`,
},
});
gulp.watch(['src/**/*.js'], ['jsdoc']).on('change', reload);
});
// Build for deployment
gulp.task('default', ['serve']);