-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
129 lines (112 loc) · 4.11 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync').create(),
autoprefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
eslint = require('gulp-eslint'),
header = require('gulp-header'),
rename = require('gulp-rename'),
cssnano = require('gulp-cssnano'),
bower = require('gulp-bower'),
notify = require('gulp-notify'),
concat = require('gulp-concat'),
package = require('./package.json');
var banner = [
'/*!\n' +
' * <%= package.name %>\n' +
' * <%= package.title %>\n' +
' * <%= package.url %>\n' +
' * @author <%= package.author %>\n' +
' * @version <%= package.version %>\n' +
' * Copyright ' + new Date().getFullYear() + '. <%= package.license %> licensed.\n' +
' */',
'\n'
].join('');
var config = {
dir: {
src: 'src',
app: 'app/assets',
bowerComp: 'bower_components'
}
};
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.dir.bowerComp));
});
gulp.task('icons', function() {
return gulp.src(config.dir.bowerComp + '/font-awesome/fonts/**.*')
.pipe(gulp.dest(config.dir.app + '/fonts'));
});
gulp.task('comps', function() {
return gulp.src([
config.dir.bowerComp + '/jquery/dist/jquery.min.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/minified/ScrollMagic.min.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/minified/plugins/animation.gsap.min.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/minified/plugins/debug.addIndicators.min.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/minified/plugins/jquery.ScrollMagic.min.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/uncompressed/ScrollMagic.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/uncompressed/plugins/animation.gsap.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/uncompressed/plugins/debug.addIndicators.js',
config.dir.bowerComp + '/scrollmagic/scrollmagic/uncompressed/plugins/jquery.ScrollMagic.js',
config.dir.bowerComp + '/gsap/src/minified/TweenMax.min.js',
config.dir.bowerComp + '/jquery-anchorscroll/jquery.anchorScroll.min.js'
])
.pipe(gulp.dest(config.dir.app + '/components'))
});
gulp.task('css', function () {
return gulp.src(config.dir.src + '/scss/style.scss')
.pipe(sass({
includePaths: [
config.dir.src + '/scss',
config.dir.bowerComp + '/vertical-rhythm-reset/dist',
config.dir.bowerComp + '/font-awesome/scss'/*,
config.dir.bowerComp + '/normalize-scss/sass'*/
]
}).on('error', notify.onError(function (error) {
return 'Error: ' + error.message;
})))
// .pipe(autoprefixer('last 4 version'))
.pipe(gulp.dest(config.dir.app + '/css'))
.pipe(cssnano())
.pipe(rename({ suffix: '.min' }))
.pipe(header(banner, { package : package }))
.pipe(gulp.dest(config.dir.app + '/css'))
.pipe(browserSync.stream());
});
gulp.task('js',function(){
return gulp.src([
config.dir.bowerComp + '/baseline/baseline.js',
config.dir.src + '/js/index.js'
])
.pipe(concat('scripts.js'))
.pipe(eslint({
configFile: '.eslintrc.json',
fix: true
}))
.pipe(eslint.format())
.pipe(eslint.failOnError())
.on('error', notify.onError(function (error) {
return 'ESLint error: ' + error.message;
}))
.pipe(header(banner, { package : package }))
.pipe(gulp.dest(config.dir.app + '/js'))
.pipe(uglify())
.pipe(header(banner, { package : package }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(config.dir.app + '/js'))
.pipe(browserSync.stream({once: true}));
});
gulp.task('serve', ['css', 'js'], function() {
browserSync.init({
server: {
baseDir: './app'
}
});
gulp.watch(config.dir.src + '/scss/**/*.scss', ['css']);
gulp.watch(config.dir.src + '/js/*.js', ['js']);
gulp.watch('app/*.html').on('change', browserSync.reload);
});
// gulp.task('bs-reload', function () {
// browserSync.reload();
// });
gulp.task('default', ['bower', 'icons', 'comps', 'serve']);