-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
38 lines (31 loc) · 1.22 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
var gulp = require('gulp');
var del = require('del');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var cssSlam = require('css-slam').gulp;
var htmlMinifier = require('gulp-html-minifier');
var HtmlSplitter = require('polymer-build').HtmlSplitter;
var mergeStream = require('merge-stream');
var PolymerProject = require('polymer-build').PolymerProject;
var project = new PolymerProject(require('./polymer.json'));
gulp.task('clean', function() {
return del(['build']);
});
gulp.task('build', ['clean'], function() {
var sourcesHtmlSplitter = new HtmlSplitter();
var sources = project.sources()
.pipe(sourcesHtmlSplitter.split())
.pipe(gulpif(/\.js$/, uglify()))
.pipe(gulpif(/\.css$/, cssSlam()))
.pipe(gulpif(/\.html$/, htmlMinifier({collapseWhitespace: true, removeComments: true,})))
.pipe(sourcesHtmlSplitter.rejoin());
var dependencies= project.dependencies()
.pipe(sourcesHtmlSplitter.split())
.pipe(gulpif(/\.js$/, uglify()))
.pipe(gulpif(/\.css$/, cssSlam()))
.pipe(gulpif(/\.html$/, htmlMinifier({collapseWhitespace: true, removeComments: true,})))
.pipe(sourcesHtmlSplitter.rejoin());
return mergeStream(sources, dependencies)
.pipe(project.bundler())
.pipe(gulp.dest('build/'));
});