forked from rtorr/newww
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
128 lines (116 loc) · 3.19 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
var gulp = require('gulp'),
nib = require('nib'),
stylus = require('gulp-stylus'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
streamify = require('gulp-streamify'),
bistre = require('bistre'),
nodemon = require('gulp-nodemon'),
rename = require('gulp-rename'),
// imagemin = require('gulp-imagemin'),
jshint = require('gulp-jshint'),
pngcrush = require('imagemin-pngcrush');
var paths = {
fonts: ['./assets/fonts/*'],
styles: ['./assets/styles/*.styl'],
images: ['./assets/images/**/*'],
misc: ['./assets/misc/*'],
scripts: {
browserify: ["./assets/scripts/*.js"],
vendor: ["./assets/scripts/vendor/*.js"],
tota11y: ["./assets/scripts/tota11y.min.js"]
},
templates: ['./assets/templates/*.hbs'],
lintables: [
"./assets/scripts/**/*.js",
"./adapters/**/*.js",
"./facets/**/*.js",
"./lib/**/*.js",
"./locales/**/*.js",
"./presenters/**/*.js",
"./services/**/*.js",
"./test/**/*.js",
]
};
gulp.task('watch', function(){
gulp.watch(paths.fonts, ['fonts']);
gulp.watch(paths.styles, ['styles']);
gulp.watch(paths.scripts.browserify, ['browserify']);
gulp.watch(paths.templates, ['browserify']);
gulp.watch(paths.scripts.vendor, ['concat']);
});
gulp.task('styles', function () {
gulp.src('./assets/styles/index.styl')
.pipe(stylus({use: [nib()]}))
.pipe(gulp.dest('static/css/'))
});
gulp.task('browserify', function () {
browserify("./assets/scripts/index.js")
.bundle()
.pipe(source('index.js'))
.pipe(gulp.dest('static/js/'))
.pipe(rename('index.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('static/js/'));
});
gulp.task('concat', function () {
gulp.src(paths.scripts.vendor)
.pipe(uglify())
.pipe(concat('vendor.min.js'))
.pipe(gulp.dest('static/js/'))
});
gulp.task('tota11y', function () {
gulp
.src(paths.scripts.tota11y)
.pipe(gulp.dest('static/js/'));
});
gulp.task('fonts', function(){
gulp.src(paths.fonts)
.pipe(gulp.dest('static/fonts'));
})
gulp.task('images', function(){
gulp.src(paths.images)
// .pipe(imagemin({
// progressive: true,
// svgoPlugins: [{removeViewBox: false}],
// use: [pngcrush()]
// }))
.pipe(gulp.dest('static/images'));
})
gulp.task('misc', function(){
gulp.src(paths.misc)
.pipe(gulp.dest('static/misc'));
})
gulp.task('nodemon', function() {
process.env.NODE_ENV = 'dev';
nodemon({
script: 'server.js',
ext: 'hbs js',
ignore: [
'assets/',
'facets/*/test/',
'node_modules/',
'static/',
'test/',
],
stdout: false,
})
.on('readable', function () {
this.stdout
.pipe(bistre({time: true}))
.pipe(process.stdout);
this.stderr
.pipe(bistre({time: true}))
.pipe(process.stderr);
});
});
gulp.task('lint', function() {
gulp.src(paths.lintables)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('build', ['fonts', 'images', 'misc', 'styles', 'browserify', 'concat', 'tota11y']);
gulp.task('dev', ['build', 'nodemon', 'watch']);
gulp.task('default', ['build']);