forked from ExpressionEngine/ExpressionEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (69 loc) · 2.21 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const { src, dest, series, watch } = require('gulp')
const ts = require('gulp-typescript')
const babel = require('gulp-babel')
const del = require('del')
const concat = require('gulp-concat')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const cleanCSS = require('gulp-clean-css');
const sourcemaps = require('gulp-sourcemaps');
const jsSourceFolder = 'themes/ee/cp/js/src/'
const jsVendorFolder = 'themes/ee/cp/js/src/vendor/'
const jsBuildFolder = 'themes/ee/cp/js/build/'
const rteRedactorFolder = 'themes/ee/asset/javascript/src/fields/rte/redactor/';
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 cleanRte() {
return del(rteRedactorFolder + '*.min.*')
}
function buildRteRedactorCss() {
return src(rteRedactorFolder + 'redactor.css')
.pipe(cleanCSS())
.pipe(rename('redactor.min.css'))
.pipe(dest(rteRedactorFolder));
}
function buildRteRedactorJs() {
return src([rteRedactorFolder + 'redactor.js', rteRedactorFolder + 'plugins/**/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('redactor.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(dest(rteRedactorFolder));
}
function buildVendorJs() {
// Vendor files are not compiled, just moved
return src(jsVendorFolder + '**/*.js')
.pipe(dest(jsBuildFolder + 'vendor/'))
}
const buildRte = series(cleanRte, buildRteRedactorCss, buildRteRedactorJs)
const buildAllJs = series(cleanJs, buildRte, buildTypeScript, buildJavascript, buildVendorJs)
function watchJs() {
watch([jsSourceFolder, jsVendorFolder, rteRedactorFolder], buildAllJs)
}
exports.rte = buildRte
exports.buildJs = buildAllJs
exports.watchJs = watchJs