This repository has been archived by the owner on Apr 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
102 lines (89 loc) · 2.76 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
var gulp = require('gulp');
var slm = require('gulp-slm');
var sass = require('gulp-sass');
var browserify = require('gulp-browserify');
var git = require('gulp-git');
var rename = require("gulp-rename");
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var fs = require('fs');
var s3 = require('gulp-s3-publish');
var sassVar = require('gulp-sass-variables');
var merge = require('merge-stream');
var marked = require('marked');
var version = ''
function task_tag(ex) {
git.exec({args : 'describe --tags'}, function done(err, stdout) {
version = stdout.trim();
console.log(version);
ex();
});
};
function task_sass() {
return gulp.src('./src/**/*.scss')
.pipe(sassVar({
$version: version
}))
.pipe(sass().on('error', sass.logError))
.pipe(rename({
suffix : '-' + version,
}))
.pipe(gulp.dest('./dist/'));
};
function task_browserify() {
return gulp.src('src/app.js')
.pipe(browserify({
insertGlobals : true,
debug : false
}))
.pipe(rename({
suffix : '-' + version,
}))
.pipe(gulp.dest('dist/'))
};
marked.setOptions({"gfm": true, "tables": true, "breaks": true, "smartypants": true, "sanitize": false });
function task_slm() {
return gulp.src('./src/*.slm')
.pipe(slm({
locals: {
marked: marked,
version: version
}}))
.pipe(gulp.dest('./dist/'))
};
function task_copy() {
return gulp.parallel(
function copy_modules() {
return gulp.src(['node_modules/**/*.css'])
.pipe(gulpif("*.css", gulp.dest('dist/node_modules/')));
},
function copy_external() {
return gulp.src(['src/external/**']).pipe(gulp.dest('dist/external/'));
},
function copy_fonts() {
return gulp.src(['node_modules/font-awesome/fonts/**']).pipe(gulp.dest('dist/fonts'));
},
function copy_assets() {
return gulp.src(['assets/**']).pipe(gulp.dest('dist/assets/'));
},
function copy_images() {
return gulp.src('src/img/**')
.pipe(rename({
suffix : '-' + version,
}))
.pipe(gulp.dest("./dist/img/"));
});
};
gulp.task('default', gulp.series(task_tag, task_sass, task_browserify, task_slm, task_copy()));
aws = JSON.parse(fs.readFileSync('./aws.json'));
gulp.task("deploy",
gulp.series(function upload_all(){
return gulp.src("./dist/**")
.pipe(gulpif('!*index.html', s3(aws, { concurrency: 5 })))
},
function upload_index() {
return gulp.src("./dist/**")
.pipe(gulpif('*index.html', s3(aws, {headers:{
'CacheControl': 'no-cache, no-store, must-revalidate'} })))
}
));