-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
86 lines (77 loc) · 2.71 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
const { src, dest, parallel, watch } = require('gulp')
const babel = require('gulp-babel')
const concat = require('gulp-concat')
const eslint = require('gulp-eslint')
const iife = require('gulp-iife')
const insert = require('gulp-insert')
const rename = require('gulp-rename')
const sass = require('gulp-sass')(require('sass'))
const sasslint = require('gulp-sass-lint');
const uglify = require('gulp-uglify')
const sassOpts = {
outputStyle: 'compressed'
}
function adminJS () {
return src('admin-js/*.js')
.pipe(concat('IntranetUserJS.js'))
.pipe(iife())
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(uglify())
.pipe(insert.prepend(`// minified ${Date()} - see https://github.com/cca/koha_snippets\n`))
.pipe(dest('dist'))
}
function catalogJS () {
return src('catalog-js/*.js')
.pipe(concat('OPACUserJS.js'))
.pipe(iife())
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(uglify())
.pipe(insert.prepend(`// minified ${Date()} - see https://github.com/cca/koha_snippets\n`))
.pipe(dest('dist'))
}
function cookieConsentedJS() {
return src('html/CookieConsentedJS.js')
.pipe(concat('CookieConsentedJS.js'))
.pipe(iife())
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(uglify())
.pipe(insert.prepend(`// minified ${Date()} - see https://github.com/cca/koha_snippets\n`))
.pipe(dest('dist'))
}
function adminCSS() {
return src('admin-scss/index.scss')
.pipe(sass(sassOpts).on('error', sass.logError))
.pipe(rename('IntranetUserCSS.css'))
.pipe(insert.prepend(`/* minified ${Date()} - see https://github.com/cca/koha_snippets */`))
.pipe(dest('dist'))
}
function catalogCSS() {
return src('catalog-scss/index.scss')
.pipe(sass(sassOpts).on('error', sass.logError))
.pipe(rename('OPACUserCSS.css'))
.pipe(insert.prepend(`/* minified ${Date()} - see https://github.com/cca/koha_snippets */`))
.pipe(dest('dist'))
}
function lint() {
return src(['admin-js/*.js', 'catalog-js/*.js', 'html/*.js'])
.pipe(eslint())
.pipe(eslint.format())
}
function stylelint() {
return src(['admin-scss/*.scss', 'catalog-scss/*.scss'])
.pipe(sasslint())
.pipe(sasslint.format())
}
module.exports = {
'admin-js': adminJS,
'catalog-js': catalogJS,
'cookie-js': cookieConsentedJS,
'admin-css': adminCSS,
'catalog-css': catalogCSS,
js: parallel(adminJS, catalogJS, cookieConsentedJS),
css: parallel(catalogCSS, adminCSS),
default: parallel(adminJS, catalogJS, adminCSS, catalogCSS),
lint: lint,
sasslint: stylelint,
test: parallel(lint, stylelint),
}