-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
gulpfile.mjs
65 lines (64 loc) · 2.46 KB
/
gulpfile.mjs
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
import gulp from 'gulp';
import {deleteAsync} from 'del';
import gp_sourcemaps from 'gulp-sourcemaps';
import gp_concat from 'gulp-concat';
import gp_rename from 'gulp-rename';
import gp_filter from 'gulp-filter';
import gp_uglify from 'gulp-uglify';
import webpack from 'webpack-stream';
const esBuildDir = 'es-build/';
gulp.task('build', gulp.series(
function () {
return gulp.src(['resources/assets/js/helpers.js'])
.pipe(webpack({
target: ['web', 'es5'],
devtool: 'inline-source-map',
mode: 'development',
output: {
filename: 'helpers.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
"plugins": [
['@babel/plugin-transform-runtime', {debug: true}]
]
}
}
}
]
}
}))
.pipe(gulp.dest(esBuildDir));
},
function () {
return gulp.src([
'node_modules/jquery-validation/dist/jquery.validate.js',
'node_modules/php-date-formatter/js/php-date-formatter.js',
'resources/assets/js/jsvalidation.js',
esBuildDir + '/helpers.js',
'resources/assets/js/timezones.js',
'resources/assets/js/validations.js'
], {base: '.'})
.pipe(gp_sourcemaps.init())
.pipe(gp_concat('jsvalidation.js'))
.pipe(gp_sourcemaps.write('./'))
.pipe(gulp.dest('public/js'))
// gp_sourcemaps will cause two files to be in the stream (common.js and common.js.map) which means
// gp_uglify will try to run on the .map file as well, resulting in an error. gulp-filter only
// passes .js files from this point (https://stackoverflow.com/a/39675819)
.pipe(gp_filter('**/*.js'))
.pipe(gp_rename({ extname: '.min.js' }))
.pipe(gp_uglify())
.pipe(gp_sourcemaps.write('./'))
.pipe(gulp.dest('public/js'));
},
function () {
return deleteAsync(esBuildDir);
}
));