Skip to content

Commit d436417

Browse files
committed
initial gulp config
1 parent 10f6f30 commit d436417

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

gulpfile.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var gulp = require('gulp'),
2+
image = require('gulp-image'),
3+
gutil = require('gulp-util'),
4+
webpack = require('webpack'),
5+
wpserver = require('webpack-dev-server'),
6+
wpconfig = require('./webpack.config.js'),
7+
rdir = require('require-dir'),
8+
events = rdir('./events'),
9+
fs = require('fs'),
10+
sortBy = require('sort-by');
11+
12+
gulp.task('events', function () {
13+
gutil.log('building events datastore...');
14+
var list = [];
15+
Object.keys(events).map(function (key) {
16+
list.push(events[key]);
17+
});
18+
19+
list.sort(sortBy('date'));
20+
21+
var json = JSON.stringify({ events: list });
22+
fs.writeFileSync('src/data.json', json);
23+
gutil.log('Loaded',list.length,'events');
24+
});
25+
26+
gulp.task('image', function () {
27+
gulp.src(['src/images/*.png','src/images/icons/*.png'])
28+
.pipe(image())
29+
.pipe(gulp.dest('./dist'));
30+
});
31+
32+
gulp.task('static', ['events'], function () {
33+
gulp.src(['src/index.html','src/images/icons/*.{xml,json}','src/data.json'])
34+
.pipe(gulp.dest('./dist'));
35+
});
36+
37+
gulp.task('webpack', ['static','image'], function (cb) {
38+
var config = Object.create(wpconfig);
39+
new wpserver(webpack(config), {
40+
contentBase: './dist',
41+
host: true,
42+
inline: true
43+
}).listen(8080,'localhost',cb);
44+
});
45+
46+
47+
gulp.task('default', ['webpack']);

0 commit comments

Comments
 (0)