-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
59 lines (50 loc) · 1.88 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
/*
* IconCaptcha - Copyright 2017-2024, Fabian Wennink (https://www.fabianwennink.nl)
* Licensed under the MIT license: https://www.fabianwennink.nl/projects/IconCaptcha-Widget/license
*
* The above copyright notice and license shall be included in all copies or substantial portions of the software.
*/
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const postcss = require('gulp-postcss');
const rename = require('gulp-rename');
const babelJS = require("gulp-babel");
const autoprefixer = require('autoprefixer');
const concat = require('gulp-concat');
const header = require('gulp-header');
const uglify = require('gulp-uglify');
const CSS_INPUT = 'src/scss/*.scss';
const CSS_OUTPUT = 'dist/css';
const JS_INPUT = ['src/js/polyfill.js', 'src/js/*.js'];
const JS_OUTPUT = 'dist/js';
const FILE_OUTPUT_NAME = 'iconcaptcha';
const HEADER = '/*! IconCaptcha v4.0.2 | (c) 2017-2024, Fabian Wennink (fabianwennink.nl) | fabianwennink.nl/projects/IconCaptcha-Widget/license */\n';
/*************************************************/
const css = () => {
return gulp.src(CSS_INPUT)
.pipe(sass({outputStyle: 'compressed'}))
.pipe(postcss([autoprefixer()]))
.pipe(header(HEADER))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(CSS_OUTPUT));
}
const js = () => {
return gulp.src(JS_INPUT)
.pipe(babelJS({
presets: ['@babel/preset-env']
}))
.pipe(concat(`${FILE_OUTPUT_NAME}.js`))
.pipe(uglify())
.pipe(header(HEADER))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(JS_OUTPUT));
}
const watch = () => {
gulp.watch(CSS_INPUT, gulp.parallel(css));
gulp.watch(JS_INPUT, gulp.parallel(js));
}
/*************************************************/
exports.js = js;
exports.css = css;
exports.watch = gulp.series(css, js, watch);
exports.default = gulp.parallel(css, js);