-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
66 lines (57 loc) · 1.79 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
const { task, series, parallel, src, dest, watch } = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const header = require('gulp-header');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const csso = require('gulp-csso');
const sourcemaps = require('gulp-sourcemaps');
const pkg = require('./package.json');
const banner = `/*!
* <%= pkg.title %> - <%= pkg.version %>
* <%= pkg.description %>
*
* <%= pkg.homepage %>
*
* Copyright <%= pkg.author %>
* Released under the <%= pkg.license %> license.
*/`
let browserifyConfig = { debug: false };
task('dev', done => {
browserifyConfig = { debug: true };
done();
});
task('browserify', () =>
browserify(Object.assign({ entries: './src/ui.js' }, browserifyConfig))
.bundle()
.pipe(source('astrobench.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(header(banner, { pkg: pkg }))
.on('error', () => this.emit('end'))
.pipe(sourcemaps.write('./'))
.pipe(dest('./dist/')));
task('uglify', () =>
src('./dist/astrobench.js')
.pipe(uglify({
output: { comments: 'some' }
}))
.pipe(concat('astrobench.min.js'))
.pipe(dest('./dist/')));
task('copy-style', () =>
src('./src/style.css')
.pipe(concat('astrobench.css'))
.pipe(dest('./dist/')));
task('minify-style', () =>
src('./dist/astrobench.css')
.pipe(sourcemaps.init())
.pipe(csso())
.pipe(sourcemaps.write('./'))
.pipe(dest('./dist/')));
task('default', parallel(
series('browserify', 'uglify'), series('copy-style', 'minify-style')));
task('watch', () => {
watch(['src/**/*.js', 'src/**/*.html'], series('dev', 'browserify'));
watch('src/**/*.css', series('copy-style'));
});