-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
107 lines (96 loc) · 2.9 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
'use strict';
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
babel = require("gulp-babel"),
browserify = require('gulp-browserify'),
cssnano = require('gulp-cssnano'),
imagemin = require('gulp-imagemin'),
pug = require('gulp-pug'),
jshint = require('gulp-jshint'),
sass = require('gulp-sass'),
stylish = require('jshint-stylish'),
uglify = require('gulp-uglify'),
gutil = require('gulp-util'),
browserSync = require('browser-sync').create();
const SRC = './src';
const DIST = './dist';
gulp.task('scripts',() => {
return gulp.src([SRC+'/js/*.js', '!./node_modules/**', '!./dist/**'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(babel({
presets: ['es2015']
}))
.pipe(browserify({
insertGlobals : true
}))
.pipe(uglify().on('error', gutil.log)) //notify(...) and continue
.pipe(gulp.dest(DIST+'/src/js'));
});
gulp.task('templates', function() {
var LOCALS = {};
gulp.src(['**/*.pug', '!./node_modules/**', '!./dist/**', '!./includes/**'])
.pipe(pug({
locals: LOCALS
}))
.pipe(gulp.dest(DIST));
});
gulp.task('images', () => {
return gulp.src([SRC+'/img/**/*', '!./node_modules/**', '!./dist/**'])
.pipe(imagemin({
optimizationLevel: 2,
progressive: true,
svgoPlugins: [
{removeViewBox: false},
{cleanupIDs: false}
]}))
.pipe(gulp.dest(DIST+'/src/img'));
});
gulp.task('sass', () => {
return gulp.src([SRC+'/scss/**/*.scss', '!./node_modules/**', '!./dist/**'])
.pipe(sass().on('error', sass.logError)) //notify(...) and continue
.pipe(autoprefixer({
browsers: ['>0.5%']
}))
// the rules here will prevent the animations from being removed
.pipe(cssnano({
discardUnused: false,
reduceIdents: false,
mergeIdents: false
}))
.pipe(gulp.dest(DIST+'/src/css'));
});
gulp.task('copy',() => {
return gulp.src(['CNAME'])
.pipe(gulp.dest(DIST));
});
gulp.task('well-known',() => {
return gulp.src(['.well-known/**/*'])
.pipe(gulp.dest(DIST + '/.well-known'));
});
gulp.task('browser-sync', () => {
browserSync.init({
server: {
baseDir: DIST
},
notify: {
styles: {
right: 'initial',
top: 'initial',
bottom: '0',
left: '0',
borderBottomLeftRadius: 'initial',
borderTopRightRadius: '1em'
}
}
});
});
gulp.task('watch',['default','browser-sync'], () => {
gulp.watch('CNAME',['copy']);
gulp.watch('**/*.pug', ['templates']);
gulp.watch(SRC+'/scss/**/*.scss', ['sass']);
gulp.watch(SRC+'/js/**/*.js', ['scripts']);
gulp.watch(SRC+'/img/**/*', ['images']);
gulp.watch('.well-known/**/*', ['well-known']);
});
gulp.task('default', ['copy','templates','sass','scripts','images','well-known']);