forked from DP6/easy-collect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
40 lines (35 loc) · 1.1 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
'use strict';
const gulp = require('gulp');
const concat = require('gulp-concat');
const beautify = require('gulp-beautify');
const include = require('gulp-include');
const strip = require('gulp-strip-comments');
const del = require('del');
const replace = require('gulp-replace');
gulp.task('gtm-modules', () =>
gulp.src(['./core/modules/*.js', './gtm/modules/*js'])
.pipe(replace(/module.exports[a-z-A-Z.]*\s*=\s*([a-zA-Z\-_]+;|([a-zA-Z\-_:.={},\n\s]+);+)/g, ''))
.pipe(concat('gtm-modules.js'))
.pipe(beautify({
indent_size: 2,
max_preserve_newlines: 2
}))
.pipe(strip())
.on('error', console.error)
.pipe(gulp.dest('./tmp'))
);
gulp.task('build-gtm', () =>
gulp.src('./gtm/main.js')
.pipe(replace(/module.exports\s*=\s*[a-zA-Z]+;/g, ''))
.pipe(include({
hardFail: true,
includePaths: [
__dirname + '/tmp',
__dirname + '/gtm',
]
}))
.on('error', console.error)
.pipe(gulp.dest('./build/gtm'))
);
gulp.task('clean', () => del(['./tmp']));
gulp.task('default', gulp.series(['clean', 'gtm-modules', 'build-gtm', 'clean']));