-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
67 lines (58 loc) · 1.74 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
var gulp = require('gulp'),
ssg = require('gulp-ssg'),
frontmatter = require('gulp-front-matter'),
marked = require('gulp-marked'),
fs = require('fs'),
es = require('event-stream'),
mustache = require('mustache'),
less = require('gulp-less'),
autoprefixer = require('gulp-autoprefixer'),
raster = require('gulp-raster'),
rename = require('gulp-rename');
var site = {
title: 'NE Mobilité 2030'
};
gulp.task('html', function() {
var template = String(fs.readFileSync('src/templates/template.html'));
return gulp.src('src/pages/**/*.html')
.pipe(frontmatter({
property: 'meta'
}))
.pipe(marked())
.pipe(ssg(site, {
property: 'meta'
}))
.pipe(es.map(function(file, cb) {
var html = mustache.render(template, {
page: file.meta,
site: site,
content: String(file.contents)
});
file.contents = Buffer.from(html);
cb(null, file);
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('less', function() {
return gulp.src('src/less/main.less')
.pipe(less())
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('dist/css'));
});
// Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch('src/less/*.less', ['less']);
});
// SVG to PNG
gulp.task('raster', function () {
return gulp.src('src/static/img/*.svg')
.pipe(raster())
.pipe(rename({extname: '.png'}))
.pipe(gulp.dest('dist/img/'));
});
// Copy static resources
gulp.task('static', function () {
return gulp.src('src/static/**/*', {encoding: false})
.pipe(gulp.dest('dist/'));
});
gulp.task('build', gulp.series('raster', 'static', 'html', 'less'));