-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (64 loc) · 2.47 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
var gulp = require('gulp')
//var request = require('request')
var clean = require('gulp-clean')
var tap = require('gulp-tap')
gulp.task('clean', function () {
//This cleans out all the contents of the dist folder
return gulp.src('dist/*', {read: false})
.pipe(tap(function(file,t) { console.log(file.path) }))
.pipe(clean());
});
gulp.task('copyComponents',['clean'],function(){
//This will copy anything in the src folder except for the components folder
//The custom components will be built by Babel
return gulp.src(['src/**/*', '!src/components/**/*'])
.pipe(tap(function(file,t) { console.log(file.path) }))
.pipe(gulp.dest('dist'));
})
gulp.task('copyBower',['clean'],function(){
return gulp.src(['bower_components/**/*'])
.pipe(gulp.dest('dist/bower_components'));
})
gulp.task('crisper',['copyComponents','copyBower'], function() {
var crisper = require('gulp-crisper')
return gulp.src('src/components/*.html')
.pipe(tap(function(file,t) { console.log(file.path) }))
.pipe(crisper({
scriptInHead: false, // true is default
onlySplit: false
}))
.pipe(gulp.dest('dist/components'));
});
gulp.task('babelify',['crisper'], function() {
var babel = require('gulp-babel')
return gulp.src('dist/components/*.js')
.pipe(tap(function(file,t) { console.log(file.path) }))
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist/components'));
});
gulp.task('vulcanize',['crisper','babelify'], function() {
//Vulcanize selected files for optimization
var vulcanize = require('gulp-vulcanize')
return gulp.src(['dist/components/icon-toggle.html'])
.pipe(vulcanize({
excludes: ['dist/bower_components/polymer/polymer.html'],
stripExcludes: false,
stripComments : true,
inlineScripts: true
//abspath: '',
//excludes: [],
//stripExcludes: false,
//inlineScripts: false
}))
.pipe(gulp.dest('dist/components'))
.pipe(tap(function(file,t) {
//Remove associating javascript file
var javascriptPath = file.path.replace('.html','.js')
console.log(javascriptPath)
return gulp.src(javascriptPath, {read: false}).pipe(clean())
}));
});
gulp.task('build', ['crisper','babelify','vulcanize']);
gulp.task('serve', require('gulp-serve')({root: ['dist']}));