This repository has been archived by the owner on May 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
71 lines (67 loc) · 1.93 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
var Vulcanize = require('vulcanize');
var gulp = require('gulp');
var through = require('through2');
var runSequence = require('run-sequence').use(gulp);
var del = require('del');
var crisper = require('gulp-crisper');
var uglifyJs = require('gulp-uglify');
var uglifyHtml = require('gulp-minify-html');
var minifyInline = require('gulp-minify-inline');
var vulcanize = new Vulcanize({
inlineScripts: true,
inlineCss: true,
stripComments: true
});
var vulcanizeWrapper = function() {
return through.obj(function(file, encoding, callback) {
var gulpContext = this;
vulcanize.process(file.path, function(err, data) {
file.contents = new Buffer(data);
gulpContext.push(file);
callback();
});
});
};
gulp.task('clean', function(cb){
del(['build/**/*'], cb)
});
gulp.task('vulcanize', function(){
return gulp.src('src/components/cic-main/element.html')
.pipe(vulcanizeWrapper())
.pipe(crisper())
.pipe(gulp.dest('build/components/cic-main'))
});
gulp.task('copy', function(){
return gulp.src('src/index.html')
.pipe(gulp.dest('build'))
});
gulp.task('minify:inline-css', function() {
return gulp.src('build/components/**/*.html')
.pipe(minifyInline({js: false}))
.pipe(gulp.dest('build/components'))
});
gulp.task('minify:js', function(){
return gulp.src('build/**/*.js')
.pipe(uglifyJs())
.pipe(gulp.dest('build'));
});
gulp.task('minify:html', function(){
return gulp.src('build/**/*.html')
.pipe(uglifyHtml())
.pipe(gulp.dest('build'));
});
gulp.task('copy_locales', function(){
return gulp.src('src/locales/*.json')
.pipe(gulp.dest('build/locales/'))
});
gulp.task('default', function() {
return runSequence(
'clean',
'vulcanize',
'copy',
'copy_locales',
'minify:js',
'minify:html',
'minify:inline-css'
);
});