This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (61 loc) · 1.67 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
'use strict';
const gulp = require('gulp');
const browserify = require('browserify');
const babelify = require('babelify');
const watchify = require('watchify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const notify = require('gulp-notify');
const moment = require('moment');
const gulpif = require('gulp-if');
const uglify = require('gulp-uglify');
const argv = require('yargs').argv;
function now() {
return moment().format('HH:mm:ss');
}
function bundle(b) {
return b
.bundle()
.on('error', notify.onError())
.pipe(source('cd.js'))
.pipe(buffer())
.pipe(gulpif(release, uglify({
mangle: false,
output: {
ascii_only: true, // Messes with \x01 \x02 \x03 \x04
},
})))
.pipe(gulp.dest('dist'));
}
const release = !!argv.release;
gulp.task('default', function () {
const obj = {
entries: ['./src/app.js'],
ignoreWatch: ['**/node_modules/**'],
poll: true,
};
if (!release) {
Object.assign(obj, {
plugin: [watchify],
}, watchify.args);
}
const b = browserify(obj)
.transform('babelify', {
presets: ['@babel/preset-env'],
// plugin-proposal-function-bind responsible for private::methods
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-function-bind',
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-async-to-generator',
],
})
.transform('node-lessify', {
textMode: true,
})
.on('update', () => bundle(b))
.on('time', time => {
console.log(now() + ' - Done in ' + (time / 1000).toFixed(1) + ' seconds');
});
return bundle(b);
});