forked from tomhschmidt/erc721-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·122 lines (110 loc) · 3.17 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
imagemin = require('gulp-imagemin'),
newer = require('gulp-newer'),
notify = require('gulp-notify'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
browserSync = require('browser-sync').create(),
cleanCSS = require('gulp-clean-css'),
del = require('del'),
filter = require('gulp-filter');
const srcPath = 'source/'; // Path to our source files
const distPath = './docs/'; // The output files, hosted by GitHub
// Remove the derived folder
gulp.task('clean', function() {
return del([distPath]);
})
// Minify images
gulp.task('imagemin', function() {
const src = srcPath + '_/img/**/*';
const dest = distPath + 'assets/img';
return gulp.src(src)
.pipe(imagemin())
.pipe(gulp.dest(dest));
});
// Compile application sass
gulp.task('minifyapp', function() {
const src = srcPath + '_/sass/**/*.scss';
const dest = distPath + 'assets/css/';
return gulp.src(src)
.pipe(sass({
'sourcemap=none': true,
outputStyle: 'expanded'
}))
.pipe(concat('app.css'))
.pipe(cleanCSS())
.pipe(gulp.dest(dest));
});
// Copy vendor css
gulp.task('minifyvendor', function() {
const src = 'node_modules/bulma/css/bulma.css';
const dest = distPath + 'assets/css/';
return gulp.src(src)
.pipe(concat('vendor.css'))
.pipe(cleanCSS())
.pipe(gulp.dest(dest));
});
// Minify application javascript
gulp.task('uglifyapp', function() {
const src = srcPath + '_/js/**/*.js';
const dest = distPath + 'assets/js/';
return gulp.src(src)
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest(dest));
});
// Minify vendor javascript
gulp.task('uglifyvendor', function() {
const src = [
'node_modules/highlightjs/highlight.pack.js',
'node_modules/highlightjs-solidity/solidity.js',
]
const dest = distPath + 'assets/js/';
return gulp.src(src)
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(gulp.dest(dest));
});
// Copy everything except the special folder _
gulp.task('copyother', function() {
const f = ['**', '!**/*/', '!**/_/**', '!**/_'];
const f2 = function(vinyl) {
return !vinyl.isDirectory()
}
return gulp.src(srcPath + '**/*')
.pipe(filter(f))
.pipe(filter(f2))
.pipe(gulp.dest(distPath));
});
// Complete regenerate the dist folder
gulp.task('dist',
gulp.series('clean',
gulp.parallel(
'imagemin',
'minifyapp',
'minifyvendor',
'uglifyapp',
'uglifyvendor',
'copyother'
)
)
);
// Watch for changes
gulp.task('watch', function() {
gulp.watch(srcPath + '_/img/**/*', gulp.task('imagemin'));
gulp.watch(srcPath + '_/sass/**/*.scss', gulp.task('minifyapp'));
gulp.watch(srcPath + 'node_modules/bulma/css/bulma.css', gulp.task('minifyvendor'));
gulp.watch(srcPath + '_/js/**/*.js', gulp.task('uglifyapp'));
gulp.watch('node_modules/**/*js', gulp.task('uglifyvendor'));
gulp.watch(srcPath, gulp.task('copyother'));
});
// BrowserSync
gulp.task('serve', gulp.parallel('watch', function() {
browserSync.init({
server: distPath
});
}));
// Tasks that run on 'gulp' command
gulp.task('default', gulp.task('serve'));