-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
44 lines (31 loc) · 1.08 KB
/
gulpfile.js
File metadata and controls
44 lines (31 loc) · 1.08 KB
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
var gulp = require('gulp');
var serve = require('gulp-serve');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var cheerio = require('gulp-cheerio');
var cssmin = require('gulp-cssmin');
var domSrc = require('gulp-dom-src');
gulp.task('serve', serve('./'));
gulp.task('js', function(){
domSrc({ file: 'index.html', selector: 'script', attribute: 'src' })
.pipe(concat('app.full.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
gulp.task('html', function(){
gulp.src('index.html')
.pipe(cheerio(function($){
$('script').remove();
$('link').remove();
$('body').append('<script src="app.full.js"></script>');
$('head').append('<link href="app.full.css" rel="stylesheet">')
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('css', function(){
domSrc({ file: 'index.html', selector: 'link', attribute: 'href' })
.pipe(cssmin())
.pipe(concat('app.full.css'))
.pipe(gulp.dest('./dist'));
});
gulp.task('build', ['css','js','html']);