-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
42 lines (36 loc) · 1021 Bytes
/
gulpfile.js
File metadata and controls
42 lines (36 loc) · 1021 Bytes
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
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var concat = require('gulp-concat');
var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var del = require('del');
// identify shopify assets
const ASSETS = './assets/';
const JS_SCRIPTS = [`${ASSETS}*.js`, `!${ASSETS}*.min.js`];
// gulp plumber error handler
const onError = (err) => {
console.log(err);
}
const scripts = () => {
return gulp.src(JS_SCRIPTS)
.pipe(plumber({
errorHandler: onError
}))
.pipe(rename(function(script){
script.extname = '.min.js';
console.log(script);
return script;
}))
.pipe(stripDebug())
.pipe(uglify())
.pipe(gulp.dest(ASSETS))
.pipe(concat('tricky3.klaviyo.pack.min.js'))
.pipe(gulp.dest(ASSETS));
}
const watcher = () => {
const tasks = ['scripts'];
gulp.watch([ASSETS, JS_SCRIPTS], gulp.parallel(tasks));
}
exports.scripts = scripts;
exports.default = gulp.parallel(watcher);