-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·128 lines (109 loc) · 3.5 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
123
124
125
126
127
128
/*
* Adam
* Automad Theme
*
* Copyright (c) 2020 by Marc Anton Dahmen
* http:/marcdahmen.de
*
* MIT license
*/
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
cleanCSS = require('gulp-clean-css'),
concat = require('gulp-concat'),
header = require('gulp-header'),
merge2 = require('merge2'),
less = require('gulp-less'),
remoteSrc = require('gulp-remote-src'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify-es').default,
gutil = require('gulp-util'),
cleanCSSOptions = {
format: { wrapAt: 500 },
rebase: false
};
// Error handling to prevent watch task to fail silently without restarting.
var onError = function(err) {
gutil.log(gutil.colors.red('ERROR', err.plugin), err.message);
gutil.beep();
new gutil.PluginError(err.plugin, err, {showStack: true})
this.emit('end');
};
// Concat minify and prefix all required js files.
gulp.task('adam-js', function() {
var uglifyOptions = {
compress: {
hoist_funs: false,
hoist_vars: false
},
output: {
comments: /(license|copyright)/i,
max_line_len: 500
}
},
pkgUIkit = require('./node_modules/uikit/package.json');
return merge2(
gulp.src([
'node_modules/jquery/dist/jquery.min.js',
'node_modules/imagesloaded/imagesloaded.pkgd.min.js'
]),
gulp.src([
// Core.
// Order of files taken from lib/vendor/uikit/uikit/gulpfile.js
'node_modules/uikit/src/js/core/core.js',
'node_modules/uikit/src/js/core/touch.js',
'node_modules/uikit/src/js/core/utility.js',
'node_modules/uikit/src/js/core/dropdown.js',
'node_modules/uikit/src/js/core/grid.js',
'node_modules/uikit/src/js/core/modal.js',
'node_modules/uikit/src/js/core/nav.js',
// Selected components.
'node_modules/uikit/src/js/components/autocomplete.js',
'node_modules/uikit/src/js/components/lightbox.js',
'node_modules/uikit/src/js/components/pagination.js',
'node_modules/uikit/src/js/components/slider.js',
'node_modules/uikit/src/js/components/slideshow.js',
'node_modules/uikit/src/js/components/tooltip.js'
])
.pipe(uglify(uglifyOptions))
.pipe(concat('uikit.js', { newLine: '\r\n\r\n' } )) // Doesn't get saved to disk.
.pipe(header('/*! <%= pkg.title %> <%= pkg.version %> | <%= pkg.homepage %> | (c) 2014 YOOtheme | MIT License */\n', { 'pkg' : pkgUIkit } )),
// Sticky sidebar.
gulp.src([
'node_modules/css-element-queries/src/ResizeSensor.js'
])
.pipe(uglify(uglifyOptions)),
gulp.src([
'node_modules/sticky-sidebar/dist/sticky-sidebar.min.js'
]),
remoteSrc([
'automad/gui/js/scroll_position.js',
'packages/standard/js/autocomplete.js',
'packages/standard/js/masonry.js',
'packages/standard/js/modal.js',
'packages/standard/js/pagination.js',
'packages/standard/js/sidebar.js'
], {
base: 'https://raw.githubusercontent.com/marcantondahmen/automad/1.5.1/'
})
.pipe(uglify(uglifyOptions))
)
.pipe(concat('adam.min.js', { newLine: '\r\n\r\n' } ))
.pipe(gulp.dest('dist'));
});
// Compile, minify and prefix alpha.less.
gulp.task('adam-less', function() {
return gulp.src('less/adam.less')
.pipe(less())
.on('error', onError)
.pipe(autoprefixer({ grid: false }))
.pipe(cleanCSS(cleanCSSOptions))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
});
// Watch task.
gulp.task('watch', function() {
gulp.watch('less/*.less', gulp.series('adam-less'));
});
// The default task.
gulp.task('default', gulp.series('adam-js', 'adam-less'));