-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
109 lines (79 loc) · 2.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
var gulp = require('gulp');
var notify = require('gulp-notify');
var browserify = require('browserify');
var through2 = require('through2');
var rename = require('gulp-rename');
var babelify = require('babelify');
var browserSync = require('browser-sync').create();
var realpathify = require('realpathify');
const sass = require('gulp-sass');
var output = './build/';
// Compile JS Files
var mainjs = "./src/index.js";
function browserified() {
return through2.obj(function(file, enc, next) {
browserify(file.path, { debug: false, })
.plugin(realpathify)
.transform("babelify", {
presets: ['@babel/preset-env'],
plugins: [
["@babel/plugin-transform-runtime", {
"regenerator": true
}]
],
global: true,
sourceMaps: true,
})
.bundle(function(err, res) {
if (err) return next(err);
file.contents = res;
next(null, file);
});
});
}
gulp.task('browserify', function() {
return gulp.src(mainjs)
.pipe(browserified())
.pipe(rename({ extname: '-master.js'}))
.pipe(gulp.dest(output));
});
gulp.task('sass', function() {
return gulp.src('src/style.sass')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(output));
});
// Copy files
gulp.task('copy-html', function() {
return gulp.src('src/*.html')
.pipe(gulp.dest(output))
.pipe(notify({message:'Copy HTML Complete', onLast:true}));
});
gulp.task('copy-wallet', function() {
return gulp.src('src/wallet.json')
.pipe(gulp.dest(output))
.pipe(notify({message:'Copy wallet Complete', onLast:true}));
});
gulp.task('reload', function () {
browserSync.reload();
return Promise.resolve();
});
gulp.task('default', gulp.series('browserify', 'sass', 'copy-wallet', 'copy-html'));
// Server
gulp.task('server', function() {
browserSync.init({
server: {
baseDir: output
},
});
});
gulp.task('watch', function () {
gulp.watch([
'src/index.js',
'node_modules/@com-chain/jsc3l-browser/build/**/*.js',
'node_modules/@com-chain/jsc3l/build/**/*.js',
], gulp.series('browserify', 'reload'));
gulp.watch('src/*.html', gulp.series('copy-html', 'reload'));
gulp.watch('src/wallet.json', gulp.series('copy-wallet', 'reload'));
gulp.watch('src/style.sass', gulp.series('sass', 'reload'));
});
gulp.task('serve', gulp.series('default', gulp.parallel('watch', 'server')));