This repository has been archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
91 lines (81 loc) · 2.16 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
/*jslint node: true */
'use strict';
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var autoprefixer = require('gulp-autoprefixer');
var pug = require('gulp-pug');
var htmlmin = require('gulp-htmlmin');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var eslint = require('gulp-eslint');
var uglify = require('gulp-uglify');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var path = {
html: 'docs/*.html',
pug: 'src/*.pug',
js: 'src/javascript/**/*.js',
jsEmbeds: 'src/javascript/3rd-party/**/*.js',
stylesWatch: 'src/styles/**/*.styl',
stylesInput: 'src/styles/styles.styl',
output: 'docs',
outputJs: 'docs/*.js',
img: 'docs/img'
};
gulp.task('styles', function () {
gulp.src(path.stylesInput)
.pipe(stylus({
paths: ['node_modules'],
'include css': true,
compress: true
}))
.pipe(autoprefixer({
cascade: false
}))
.pipe(gulp.dest(path.output))
.pipe(browserSync.stream());
});
gulp.task('scripts', function() {
return gulp.src([path.js, '!'+path.jsEmbeds])
.pipe(concat('app.js'))
.pipe(gulp.dest(path.output));
});
gulp.task('uglify', function() {
return gulp.src('docs/app.js')
.pipe(uglify())
.pipe(gulp.dest(path.output));
});
gulp.task('lint', function() {
return gulp.src(path.js).pipe(eslint({
'rules':{
'semi': [1, 'always']
}
}))
.pipe(eslint.format());
});
gulp.task('minify', function () {
return gulp.src(path.pug)
.pipe(pug())
.pipe(htmlmin({
collapseWhitespace: true
}))
.pipe(gulp.dest(path.output));
});
gulp.task('observeFiles', function () {
gulp.watch(path.stylesWatch, ['styles']);
gulp.watch(path.js, ['lint', 'scripts']);
gulp.watch(path.pug, ['minify']);
gulp.watch(path.html).on('change', reload);
gulp.watch(path.outputJs).on('change', reload);
});
gulp.task('browserSync', function () {
browserSync.init({
server: {
baseDir: path.output,
index: 'index.html'
}
});
});
gulp.task('build', ['styles', 'scripts', 'minify']);
gulp.task('publish', ['build', 'uglify']);
gulp.task('default', ['build', 'observeFiles', 'browserSync']);