-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgulpfile.js
63 lines (52 loc) · 1.65 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
var gulp = require('gulp');
var merge = require('merge-stream');
var del = require('del');
var serve = require('gulp-serve');
var rename = require('gulp-rename');
var inlinesource = require('gulp-inline-source');
var stylus = require('gulp-stylus');
var src = 'src/**/';
var dependencies = [
// '//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js',
// 'node_modules/contentful-ui-extensions-sdk/dist/cf-extension.css',
// 'node_modules/contentful-ui-extensions-sdk/dist/cf-extension-api.js',
];
gulp.task('default', ['build'], function () {
gulp.start('serve');
});
// Serve and watch for changes so we don't have to run `gulp` after each change.
gulp.task('watch', ['build'], function () {
gulp.start('serve');
gulp.watch([src + '*', dependencies], function () {
gulp.start(['build']);
});
});
// Serve dist folder on port 3000 for local development.
gulp.task('serve', serve({
root: 'dist'
}));
// Copy required dependencies into dist folder.
gulp.task('build', ['stylus'], function () {
var filesStream = gulp.src(src + '!(*.styl)')
.pipe(gulp.dest('./dist'));
var depsStream = gulp.src(dependencies)
.pipe(gulp.dest('./dist/lib'));
return merge(filesStream, depsStream);
});
gulp.task('stylus', function () {
return gulp.src(src + '*.styl')
.pipe(stylus())
.pipe(gulp.dest('./dist'));
});
// Bundles the whole widget into one file which can be uploaded to Contentful.
gulp.task('bundle', ['build'], function () {
return gulp.src('./dist/index.html')
.pipe(rename('index.min.html'))
.pipe(inlinesource())
.pipe(gulp.dest('./dist'));
});
gulp.task('clean', function () {
return del([
'./dist'
]);
});