forked from ExpressionEngine/ExpressionEngine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
55 lines (44 loc) · 1.31 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
const { src, dest, series, watch } = require('gulp')
const ts = require('gulp-typescript')
const babel = require('gulp-babel')
const del = require('del')
const jsSourceFolder = 'themes/ee/cp/js/src/'
const jsVendorFolder = 'themes/ee/cp/js/src/vendor/'
const jsBuildFolder = 'themes/ee/cp/js/build/'
function cleanJs() {
return del([jsBuildFolder + '**/*'])
}
function buildTypeScript() {
return src([jsSourceFolder + '**/*.ts', jsSourceFolder + '**/*.tsx', '!' + jsVendorFolder + '**/*'])
.pipe(ts({
noImplicitAny: false,
jsx: "react",
target: "es5",
isolatedModules: true
}))
.pipe(dest(jsBuildFolder))
}
function buildJavascript() {
return src([jsSourceFolder + '/**/*.js', jsSourceFolder + '/**/*.jsx', '!' + jsVendorFolder + '**/*'])
.pipe(babel({
presets: [
'@babel/env',
'@babel/preset-react'
],
plugins: [
'@babel/plugin-proposal-class-properties'
]
}))
.pipe(dest(jsBuildFolder))
}
function buildVendorJs() {
// Vendor files are not compiled, just moved
return src(jsVendorFolder + '**/*.js')
.pipe(dest(jsBuildFolder + 'vendor/'))
}
const buildAllJs = series(cleanJs, buildTypeScript, buildJavascript, buildVendorJs)
function watchJs() {
watch([jsSourceFolder, jsVendorFolder], buildAllJs)
}
exports.buildJs = buildAllJs
exports.watchJs = watchJs