1
|
|
|
// Gulp.js configuration |
2
|
|
|
|
3
|
|
|
// Modules |
4
|
|
|
const { src, dest, series } = require('gulp'); |
5
|
|
|
const concat = require('gulp-concat'); |
6
|
|
|
// const deporder = require('gulp-deporder'); |
7
|
|
|
const rename = require('gulp-rename'); |
8
|
|
|
// const stripdebug = require('gulp-strip-debug'); |
9
|
|
|
const terser = require('gulp-terser'); |
10
|
|
|
|
11
|
|
|
// Folders and files |
12
|
|
|
const folders = { |
13
|
|
|
src: './src/', |
14
|
|
|
dist: './dist/', |
15
|
|
|
lang: './dist/lang/', |
16
|
|
|
libs: './dist/libs/', |
17
|
|
|
}; |
18
|
|
|
const files = { |
19
|
|
|
src: { |
20
|
|
|
core: [ |
21
|
|
|
folders.src + 'config.js', |
22
|
|
|
folders.src + 'utils/*.js', |
23
|
|
|
folders.src + 'libs/*.js', |
24
|
|
|
folders.src + 'parser/*.js', |
25
|
|
|
folders.src + 'ajax/*.js', |
26
|
|
|
folders.src + 'cmd/*.js', |
27
|
|
|
folders.src + 'jaxon.js', |
28
|
|
|
], |
29
|
|
|
module: folders.src + 'module.js', |
30
|
|
|
}, |
31
|
|
|
dist: { |
32
|
|
|
core: 'jaxon.core.js', |
33
|
|
|
debug: 'jaxon.debug.js', |
34
|
|
|
module: 'jaxon.module.js', |
35
|
|
|
chibi: 'chibi.js', |
36
|
|
|
lang: [ |
37
|
|
|
folders.dist + 'lang/jaxon.bg.js', |
38
|
|
|
folders.dist + 'lang/jaxon.de.js', |
39
|
|
|
folders.dist + 'lang/jaxon.en.js', |
40
|
|
|
folders.dist + 'lang/jaxon.es.js', |
41
|
|
|
folders.dist + 'lang/jaxon.fr.js', |
42
|
|
|
folders.dist + 'lang/jaxon.nl.js', |
43
|
|
|
folders.dist + 'lang/jaxon.tr.js' |
44
|
|
|
], |
45
|
|
|
}, |
46
|
|
|
}; |
47
|
|
|
|
48
|
|
|
// Concat the core library files |
49
|
|
|
const js_core = () => src(files.src.core) |
50
|
|
|
// .pipe(deporder()) |
51
|
|
|
.pipe(concat(files.dist.core, {newLine: "\n\n"})) |
52
|
|
|
.pipe(dest(folders.dist)); |
53
|
|
|
|
54
|
|
|
// Concat the core library files into a module |
55
|
|
|
const js_module = () => src([...files.src.core, files.src.module]) |
56
|
|
|
// .pipe(deporder()) |
57
|
|
|
.pipe(concat(files.dist.module, {newLine: "\n\n"})) |
58
|
|
|
.pipe(dest(folders.dist)); |
59
|
|
|
|
60
|
|
|
// Minify the core library files |
61
|
|
|
const js_core_min = () => src(folders.dist + files.dist.core) |
62
|
|
|
// .pipe(stripdebug()) |
63
|
|
|
.pipe(terser()) |
64
|
|
|
.pipe(rename({ extname: '.min.js' })) |
65
|
|
|
.pipe(dest(folders.dist)); |
66
|
|
|
|
67
|
|
|
// Minify the jaxon.debug.js file |
68
|
|
|
const js_debug_min = () => src(folders.dist + files.dist.debug) |
69
|
|
|
// .pipe(stripdebug()) |
70
|
|
|
.pipe(terser()) |
71
|
|
|
.pipe(rename({ extname: '.min.js' })) |
72
|
|
|
.pipe(dest(folders.dist)); |
73
|
|
|
|
74
|
|
|
// Minify the chibi.js file |
75
|
|
|
const js_chibi_min = () => src(folders.libs + 'chibi/' + files.dist.chibi) |
76
|
|
|
// .pipe(stripdebug()) |
77
|
|
|
.pipe(terser()) |
78
|
|
|
.pipe(rename({ extname: '.min.js' })) |
79
|
|
|
.pipe(dest(folders.libs + 'chibi/')); |
80
|
|
|
|
81
|
|
|
// Minify the jaxon language files |
82
|
|
|
const js_lang_min = () => src(files.dist.lang) |
83
|
|
|
// .pipe(stripdebug()) |
84
|
|
|
.pipe(terser()) |
85
|
|
|
.pipe(rename({ extname: '.min.js' })) |
86
|
|
|
.pipe(dest(folders.lang)); |
87
|
|
|
|
88
|
|
|
exports.default = series(js_core, js_module, js_core_min, js_debug_min, js_chibi_min, js_lang_min); |
89
|
|
|
exports.js_core = js_core; |
90
|
|
|
|