-
Notifications
You must be signed in to change notification settings - Fork 22
/
gulpfile.js
105 lines (87 loc) · 2.84 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
/*
The BSD 3-Clause License
Copyright 2016,2017,2018 - Klaus Landsdorf (http://bianco-royal.de/)
All rights reserved.
node-red-contrib-iiot-opcua
*/
'use strict'
const gulp = require('gulp')
const htmlmin = require('gulp-htmlmin')
const jsdoc = require('gulp-jsdoc3')
const clean = require('gulp-clean')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const sequence = require('gulp-sequence')
const sourcemaps = require('gulp-sourcemaps')
const pump = require('pump')
const replace = require('gulp-replace')
gulp.task('default', function () {
// place code for your default task here
})
gulp.task('docs', sequence('doc', 'docIcons', 'docImages'))
gulp.task('build', sequence('clean', 'web', 'nodejs', 'locale', 'code', 'public', 'icons'))
gulp.task('publish', sequence('build', 'maps', 'docs'))
gulp.task('icons', function () {
return gulp.src('src/icons/**/*').pipe(gulp.dest('opcuaIIoT/icons'))
})
gulp.task('docIcons', function () {
return gulp.src('src/icons/**/*').pipe(gulp.dest('docs/gen/icons'))
})
gulp.task('docImages', function () {
return gulp.src('images/**/*').pipe(gulp.dest('docs/gen/images'))
})
gulp.task('locale', function () {
return gulp.src('src/locales/**/*').pipe(gulp.dest('opcuaIIoT/locales'))
})
gulp.task('public', function () {
return gulp.src('src/public/**/*').pipe(gulp.dest('opcuaIIoT/public'))
})
gulp.task('maps', function () {
return gulp.src('maps/**/*').pipe(gulp.dest('opcuaIIoT/maps'))
})
gulp.task('clean', function () {
return gulp.src(['opcuaIIoT', 'docs/gen', 'maps', 'code', 'coverage', 'jcoverage', 'suite/jcoverage', 'pki', 'suite/pki', 'test/pki'])
.pipe(clean({ force: true }))
})
gulp.task('web', function () {
return gulp.src('src/*.htm*')
.pipe(htmlmin({
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
maxLineLength: 120,
preserveLineBreaks: false,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
conservativeCollapse: true,
processScripts: ['text/x-red'],
quoteCharacter: "'"
}))
.pipe(gulp.dest('opcuaIIoT'))
})
gulp.task('nodejs', function (cb) {
let anchor = '// SOURCE-MAP-REQUIRED'
pump([
gulp.src('src/**/*.js')
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(replace(anchor, 'require(\'source-map-support\').install()'))
.pipe(babel({ presets: ['@babel/env'] }))
.pipe(uglify())
.pipe(sourcemaps.write('maps')), gulp.dest('opcuaIIoT')],
cb
)
})
gulp.task('nodejsclearly', function (cb) {
gulp.src('src/**/*.js')
.pipe(babel({ presets: ['@babel/env'] }))
.pipe(gulp.dest('code'))
})
gulp.task('doc', function (cb) {
gulp.src(['README.md', 'src/**/*.js'], { read: false })
.pipe(jsdoc(cb))
})
gulp.task('code', function () {
gulp.src('src/**/*.js')
.pipe(babel({ presets: ['@babel/env'] }))
.pipe(gulp.dest('code'))
})