-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
61 lines (50 loc) · 1.41 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
var gulp = require('gulp'),
domSrc = require('gulp-dom-src'),
concat = require('gulp-concat'),
cssmin = require('gulp-cssmin'),
uglify = require('gulp-uglify'),
htmlmin = require('gulp-htmlmin'),
cheerio = require('gulp-cheerio');
gulp.task('css', function() {
return domSrc({ file: 'index.html', selector: 'link', attribute: 'href' })
.pipe(concat('style.min.css'))
.pipe(cssmin())
.pipe(gulp.dest('dist/css/'));
});
gulp.task('js', function() {
return domSrc({ file: 'index.html', selector: 'script', attribute: 'src' })
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/src/'));
});
gulp.task('html', function() {
return gulp.src('index.html')
.pipe(concat('index.html'))
.pipe(cheerio(function($) {
$('script').remove();
$('link').remove();
$('body').append('<script src="src/app.min.js"></script>');
$('head').append('<link rel="stylesheet" href="css/style.min.css">');
}))
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('build', ['css','js','html']);
// inject bower components
gulp.task('wiredep', function (){
var wiredep = require('wiredep').stream;
gulp.src('css/*.css')
.pipe(wiredep({
directory: 'lib/'
}))
.pipe(gulp.dest('app/styles'));
gulp.src('view/index.html')
.pipe(wiredep({
directory: 'lib/',
exclude: ['bootstrap-sass-official']
}))
.pipe(gulp.dest('./'));
});