forked from DataArt/chip-in-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (71 loc) · 2.05 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
73
74
75
const Vulcanize = require('vulcanize');
const gulp = require('gulp');
const through = require('through2');
const runSequence = require('run-sequence').use(gulp);
const del = require('del');
const crisper = require('gulp-crisper');
const uglifyJs = require('gulp-uglify');
const uglifyHtml = require('gulp-minify-html');
const uglifyCss = require('gulp-minify-css');
const vulcanize = new Vulcanize({
inlineScripts: true,
inlineCss: true,
stripComments: true
});
const 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([
'bower_components/webcomponentsjs/webcomponents.min.js',
'bower_components/page/page.js',
'bower_components/parse/parse.min.js',
'src/index.html'
]).pipe(gulp.dest('build'))
});
gulp.task('minify:css', function(){
return gulp.src('src/**/*.css')
.pipe(uglifyCss())
.pipe(gulp.dest('build'));
});
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:css',
'minify:js',
'minify:html'
);
});