-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
105 lines (93 loc) · 2.62 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var terser = require('gulp-terser');
var header = require('gulp-header');
var babel = require('gulp-babel');
var browserjs = ['src/_head.js',
'src/QueryBuilder/IDB.js',
'src/QueryBuilder/SQL.js',
'src/Structures/IDB.js',
'src/Structures/WebSQL.js',
'src/_foot.js'];
var nodejs = ['src/_head.js',
'src/QueryBuilder/SQL.js',
'src/Structures/MySQL.js',
'src/Structures/SQLite3.js',
'src/_foot.js'];
gulp.task('browserjs', function(){
return gulp.src(browserjs)
.pipe(sourcemaps.init())
.pipe(concat('sfdatabase.min.js'))
.pipe(babel({
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": "50"
},
"modules": false,
"loose": false,
"shippedProposals": true
}
]
]
}))
.on('error', swallowError)
.pipe(terser())
.on('error', swallowError)
.pipe(header(`/*
SFDatabase-js
SFDatabase-js is a database library that can help you
build a SQL Query and execute it to the server from
Nodejs or local browser with WebSQL.
https://github.com/ScarletsFiction/SFDatabase-js
*/\n`))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
// for debugging: npm install --save-dev source-map-support
gulp.task('nodejs', function(){
return gulp.src(nodejs)
.pipe(sourcemaps.init())
.pipe(concat('sfdatabase.node.js'))
.on('error', swallowError)
.pipe(header(`/*
SFDatabase-js
SFDatabase-js is a database library that can help you
build a SQL Query and execute it to the server from
Nodejs or local browser with WebSQL.
https://github.com/ScarletsFiction/SFDatabase-js
*/\n`))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function() {
gulp.watch(browserjs, gulp.parallel(['browserjs', 'nodejs']));
});
gulp.task('serve', function() {
browserSync({
ghostMode: false, // Use synchronization between browser?
ui: false,
open: false,
server: {
baseDir: 'example',
routes: {
"/dist": "dist"
}
}
});
console.log("Please modify one file from /src to trigger the first build");
// gulp.watch(['*.html', 'src/**/*.js'], {cwd: 'example'}, reload);
gulp.watch(['*.html', 'src/**/*.js'], gulp.parallel([
'browserjs', 'nodejs'
]));
});
gulp.task('default', gulp.parallel(['browserjs', 'nodejs']));
function swallowError(error){
console.log(error.message)
this.emit('end')
}