-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
73 lines (65 loc) · 2.19 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
'use strict';
var gulp = require('gulp');
var inject = require('gulp-inject');
var concat = require('gulp-concat');
var filter = require('gulp-filter');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var uglify = require('gulp-uglify');
var cleanCSS = require('gulp-clean-css');
var browserify = require('gulp-browserify');
var flatten = require('gulp-flatten');
var sass = require('gulp-sass');
var mainBowerFiles = require('gulp-main-bower-files');
browserify = require('gulp-browserify');
gulp.task('default', ['vendor', 'app']);
gulp.task('app', function() {
var filters = {
"css": filter('**/*.css', {restore: true}),
"sass": filter('**/*.scss', {restore: true})
}
gulp.src('./src/scripts/main.js')
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(browserify({
insertGlobals: true
}))
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('./scripts/'))
return gulp.src('./src/**/*')
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(filters.sass)
.pipe(sass())
.pipe(filters.sass.restore)
.pipe(filters.css)
.pipe(concat('app.css'))
.pipe(cleanCSS())
.pipe(gulp.dest('./styles'))
.pipe(filters.css.restore);
});
gulp.task('vendor', function() {
var filters = {
'css': filter('**/*.css', {restore: true}),
'sass': filter(['**/*.scss', '**/*.sass'], {restore: true}),
'js': filter('**/*.js', {restore: true})
}
return gulp.src('bower.json')
.pipe(mainBowerFiles())
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(filters.sass)
.pipe(sass())
.pipe(filters.sass.restore)
.pipe(filters.css)
.pipe(concat('vendor.css'))
.pipe(cleanCSS())
.pipe(gulp.dest('./styles'))
.pipe(filters.css.restore)
.pipe(filters.js)
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(gulp.dest('./scripts'))
.pipe(filters.js.restore);
});
gulp.task('watch', ['app'], function() {
gulp.watch('./src/**/*', ['app']);
});