-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
80 lines (73 loc) · 2.1 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
const gulp = require('gulp')
, ejs = require('gulp-ejs')
, livereload = require('gulp-livereload')
, nodemon = require('gulp-nodemon')
, rename = require('gulp-rename')
, stylus = require('gulp-stylus')
, svgmin = require('gulp-svgmin')
, svgstore = require('gulp-svgstore')
, nib = require('nib')
, webpack = require('webpack-stream')
, webpack_config = require('./webpack.config.js')
;
const config = name => typeof process.env[name] !== 'undefined' ? process.env[name] : require('./env.json')[name];
gulp.task('css', function() {
return gulp.src('src/styl/app.styl')
.pipe(stylus({
use: nib(),
import: ['nib']
}))
.pipe(gulp.dest('public/css'))
.pipe(livereload());
});
gulp.task('html', function() {
return gulp.src('src/ejs/*.ejs')
.pipe(ejs({
data: {
defaultVotes: config('default_votes'),
env: config('NODE_ENV'),
firebase: {
apiKey: config('FIREBASE_KEY'),
authDomain: config('FIREBASE_DOMAIN'),
databaseURL: config('FIREBASE_DBURL'),
projectId: config('FIREBASE_NAME'),
storageBuckets: config('FIREBASE_STORE'),
appId: config('FIREBASE_APP')
}
}
}))
.pipe(rename({ extname: '.html' }))
.pipe(gulp.dest('public'))
.pipe(livereload());
});
gulp.task('svg', function() {
return gulp.src('src/icons/*.svg')
.pipe(svgmin({
plugins: [
{ removeViewBox: false },
{ removeDimensions: true }
]
}))
.pipe(svgstore())
.pipe(gulp.dest('public/img/'))
.pipe(livereload());
});
gulp.task('webpack', function() {
return gulp.src('src/client/main.js')
.pipe(webpack(webpack_config))
.pipe(gulp.dest('public/js/'))
.pipe(livereload());
});
gulp.task('watch', function() {
livereload.listen();
nodemon().on('restart', function() {
gulp.src('src/server/app.js')
.pipe(livereload());
});
gulp.watch('src/styl/**/*.styl', gulp.task('css'));
gulp.watch('src/server/views/*.ejs', gulp.task('html'));
gulp.watch('src/img/**/*.svg', gulp.task('svg'));
gulp.watch('src/client/**/*.js', gulp.task('webpack'));
});
gulp.task('build', gulp.series('css', 'html', 'svg', 'webpack'));
gulp.task('default', gulp.series('build', 'watch'));