-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgulpfile.js
126 lines (119 loc) · 4.42 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const { src, dest, watch, series } = require('gulp');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var eslint = require('gulp-eslint');
var notify = require('gulp-notify');
var minify = require('gulp-minify');
var jsFiles = {
vendor: [
'resources/scripts/lib/react/react-with-addons.js',
'public/js/select2.full.js',
'resources/scripts/lib/underscore.js',
'resources/scripts/lib/backbone.js',
'resources/scripts/lib/director.min.js',
'resources/scripts/lib/pdfjs/pdf.js',
'resources/scripts/lib/jquery-ui.min.js',
'resources/scripts/lib/jbox.js'
],
source: [
'resources/scripts/contract.view/views/react.pdf.js',
'resources/scripts/contract.view/views/react.waypoint.js',
'resources/scripts/contract.view/views/text.view.js',
'resources/scripts/contract.view/views/text.search.js',
'resources/scripts/contract.view/views/annotations.view.js',
'resources/scripts/contract.view/views/metadata.view.js',
'resources/scripts/contract.view/rc.utils.js',
'resources/scripts/contract.view/models/pages.js',
'resources/scripts/contract.view/models/annotations.js',
'resources/scripts/contract.view/models/search.js',
'resources/scripts/contract.view/models/metadata.js',
'resources/scripts/contract.view/models/contract.js',
'resources/scripts/contract.view/models/pdf.js',
'resources/scripts/lib/annotator/annotator-full.min.js',
'resources/scripts/contract.view/annotation/annotator.utils.js',
'resources/scripts/contract.view/annotation/rc.annotator.js',
'resources/scripts/contract.view/annotation/annotator.plugin.categories.js',
'resources/scripts/contract.view/annotation/annotator.plugin.viewer.js',
'resources/scripts/contract.view/annotation/annotator.plugin.event.js',
'resources/scripts/contract.view/annotation/annotator.plugin.article_reference.js',
'resources/scripts/contract.view/annotation/annotator.plugin.parentannotation.js',
'resources/scripts/contract.view/annotation/annotator.plugin.language.js',
'resources/scripts/lib/pdf-annotator.js'
],
main: [
'resources/scripts/contract.view/views/pdf.view.js',
'resources/scripts/contract.view/views/main.view.js'
],
review: [
'resources/scripts/contract.view/views/pdf.view.for.text.edit.js',
'resources/scripts/contract.view/views/text.edit.js',
'resources/scripts/contract.view/views/review.main.view.js'
]
};
function eslint_task() {
return src(jsFiles.source)
.pipe(eslint({
baseConfig: {
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
}
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function js_main() {
return src(jsFiles.vendor.concat(jsFiles.source).concat(jsFiles.main))
.pipe(sourcemaps.init())
.pipe(babel({
only: [
'resources/scripts/contract.view/views'
],
presets: [
'@babel/preset-react'
],
compact: false
}))
.pipe(concat('app.js'))
.pipe(sourcemaps.write('./'))
.pipe(minify({
ext: {
src: '-debug.js',
min: '.js'
}
}))
.pipe(dest('public/assets/js'))
.pipe(notify("JS-main build complete."));
}
function js_review() {
return src(jsFiles.vendor.concat(jsFiles.source).concat(jsFiles.review))
.pipe(sourcemaps.init())
.pipe(babel({
only: [
'resources/scripts/contract.view/views'
],
presets: [
'@babel/preset-react'
],
compact: false
}))
.pipe(concat('review.js'))
.pipe(sourcemaps.write('./'))
.pipe(minify({
ext: {
src: '-debug.js',
min: '.js'
}
}))
.pipe(dest('public/assets/js'));
}
function file_watch() {
watch('resources/scripts/contract.view/**/*.{js,jsx}', series(js_main));
}
concat_task = series(eslint_task, js_main, js_review)
build = series(concat_task)
exports.build = build
exports.default = series(build, file_watch);