-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (83 loc) · 2.53 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var watchify = require('watchify');
var exorcist = require('exorcist');
var sass = require('gulp-sass');
var scsslint = require('gulp-scss-lint');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var jshint = require('gulp-jshint');
var src = {
scss: './scss/**/*.scss',
css: './css',
html: './*.html'
};
var sassOptions = {
errLogToConsole: true,
outputStyle: 'expanded'
};
function bundle(bundler) {
return bundler
.bundle()
.on('error', function (e) {
gutil.log(e);
})
.pipe(exorcist('./js/dist/app.js.map'))
.pipe(source('bundle.js'))
.pipe(gulp.dest('./js/dist'))
.pipe(browserSync.stream());
}
gulp.task('watch', function () {
watchify.args.debug = true;
var watcher = watchify(browserify('./js/app.js', watchify.args));
bundle(watcher);
watcher.on('update', function () {
bundle(watcher);
})
watcher.on('log', gutil.log);
gulp.watch(src.scss, ['sass']).on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
gulp.watch(src.html).on('change', reload);
browserSync.init({
server: "./",
logFileChanges: false
});
})
gulp.task('js', function () {
return bundle(browserify('./js/app.js'));
});
gulp.task('sass', function () {
return gulp
.src(src.scss)
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(autoprefixer())
.pipe(gulp.dest(src.css))
.pipe(browserSync.stream());
});
gulp.task('scss-lint', function() {
return gulp.src(src.scss)
.pipe(scsslint({
'config': '.scss-lint.yml'
}));
});
gulp.task('fonts', function() {
return gulp.src(['./node_modules/font-awesome/fonts/fontawesome-webfont.*'])
.pipe(gulp.dest('./fonts/'));
});
gulp.task('externalcss', function() {
return gulp.src(['./node_modules/normalize.css/*.css'])
.pipe(gulp.dest('./css/libs/'));
});
gulp.task('jshint', function () {
return gulp.src('./js/src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
})
gulp.task('default', ['fonts', 'js', 'externalcss', 'sass', 'scss-lint']);