This repository has been archived by the owner on Oct 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
96 lines (82 loc) · 2.3 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
'use strict';
const gulp = require('gulp');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const del = require('del');
const rev = require('gulp-rev');
const revReplace = require('gulp-rev-css-url');
const ASSET_PATH = './assets';
const SASS_PATH = ASSET_PATH + '/stylesheets';
const IMAGES_PATH = ASSET_PATH + '/images';
const JS_PATH = ASSET_PATH + '/javascripts';
const FONTS_PATH = `${ASSET_PATH}/fonts`;
const BUILD_PATH = './public';
const NODE_MODULES_PATH = './node_modules';
//*** SASS compiler task
gulp.task('sass', function () {
return gulp.src(SASS_PATH + '/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(BUILD_PATH + '/css'));
});
//*** SASS watch(realtime) compiler task
gulp.task('sass:watch', function () {
gulp.watch([
SASS_PATH + '/**/*.scss',
SASS_PATH + '/**/**/*.scss'
], ['sass']);
});
gulp.task('copy:images', function() {
gulp.src([
`${ASSET_PATH}/favicon/*`,
]).pipe(gulp.dest(BUILD_PATH));
gulp.src([
`${ASSET_PATH}/badges/*`,
]).pipe(gulp.dest(`${BUILD_PATH}/badges`));
gulp.src([
IMAGES_PATH + '/**/*.png',
IMAGES_PATH + '/**/*.svg'
]).pipe(gulp.dest(BUILD_PATH + '/img'))
});
gulp.task('copy:fonts', function () {
gulp.src([
`${FONTS_PATH}/*`
]).pipe(gulp.dest(BUILD_PATH + '/fonts'));
});
gulp.task('js', function() {
gulp.src([
JS_PATH + '/*.js',
JS_PATH + '/**/*.js'
])
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(BUILD_PATH + '/js'))
});
gulp.task('copy:swagger-ui', function() {
gulp.src([
`${NODE_MODULES_PATH}/swagger-ui-dist/swagger-ui*`
])
.pipe(gulp.dest(BUILD_PATH + '/vendor/swagger-ui'))
});
gulp.task('clean', function() {
return del([
`${BUILD_PATH}/**/*.*`,
`!${BUILD_PATH}/.gitignore`
]);
});
gulp.task('build', function() {
gulp.start(['sass', 'copy:images', 'copy:fonts', 'js', 'copy:swagger-ui'], function() {
gulp.src([
BUILD_PATH + '/**/*.*',
`!${BUILD_PATH}/**/*-${'[0-9a-f]'.repeat(10)}.*`,
])
.pipe(rev())
.pipe(revReplace())
.pipe(gulp.dest(BUILD_PATH))
.pipe(rev.manifest())
.pipe(gulp.dest(BUILD_PATH))
});
});