-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·61 lines (50 loc) · 1.75 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
/* jshint node: true */
'use strict';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
inlinesource = require('gulp-inline-source');
gulp.task('lint', function () {
return gulp.src(['src/js/**/*.js', '*.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('sass', function () {
return gulp.src('src/sass/style.scss')
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(concat('style.min.css'))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('dist/css'));
});
gulp.task('js-min', function () {
return gulp.src('src/js/script.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(concat('script.min.js'))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('copy', function () {
return gulp.src(['src/worker.js', 'src/serviceworker-cache-polyfill.js', 'src/manifest.json'])
.pipe(gulp.dest('dist'));
});
gulp.task('copy-index', ['sass'], function () {
return gulp.src('src/index.html')
.pipe(inlinesource())
.pipe(gulp.dest('dist'));
});
gulp.task('copy-images', function () {
return gulp.src(['src/images/**/*.jpg', 'src/images/**/*.gif', 'src/images/**/*.png', 'src/images/**/*.svg'])
.pipe(gulp.dest('dist/images'));
});
gulp.task('watch', function () {
gulp.watch('src/sass/**/*.scss', ['sass', 'copy']);
gulp.watch('src/js/**/*.js', ['lint', 'js-min']);
gulp.watch(['src/worker.js', 'src/manifest.json'], ['copy']);
gulp.watch('src/index.html', ['copy-index']);
});
gulp.task('build', ['lint', 'sass', 'js-min', 'copy', 'copy-index', 'copy-images']);