-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
56 lines (47 loc) · 1.17 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
// module dependencies
var webpackStream = require('webpack-stream');
var inject = require('gulp-js-text-inject');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var gulp = require('gulp');
// config
var config = {
watch: './build/**/*',
themes: './build/themes/',
lib: {
src: [
'./lib/script-tag-data/script-tag-data.js',
'./build/repo-card.js'
],
rename: 'repo-card.js',
minify: 'repo-card.min.js',
dest: './'
},
webpack: {
output: {
libraryTarget: 'umd',
library: 'RepoCard'
}
}
};
// minify and write contents
gulp.task('scripts', function() {
gulp.src(config.lib.src)
.pipe(webpackStream(config.webpack))
.pipe(inject({
basepath: config.themes
}))
.pipe(concat(config.lib.rename))
.pipe(gulp.dest(config.lib.dest))
.pipe(uglify())
.pipe(rename(config.lib.minify))
.pipe(gulp.dest(config.lib.dest));
});
// watch the js file for changes
gulp.task('watch', function() {
gulp.watch(config.watch, ['build']);
});
// command line task commands
gulp.task('build', ['scripts']);
gulp.task('default', ['build', 'watch']);