-
Notifications
You must be signed in to change notification settings - Fork 46
/
gulpfile.js
51 lines (45 loc) · 1.19 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
var gulp = require('gulp');
var del = require('del');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var header = require('gulp-header');
var footer = require('gulp-footer');
var paths = {
scripts: ['src/hermite.js']
};
//prepare comments
var pkg = require('./package.json');
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
//clear dist dir
gulp.task('clean', function () {
return del(['dist']);
});
// Minify scripts
gulp.task('scripts-browser', function () {
return gulp.src(paths.scripts)
.pipe(uglify())
.pipe(concat('hermite.js'))
.pipe(header(banner, { pkg : pkg } ))
.pipe(footer("\n"))
.pipe(gulp.dest('dist'));
});
// Minify scripts for NPM
gulp.task('scripts-npm', function () {
return gulp.src(paths.scripts)
.pipe(uglify())
.pipe(concat('hermite.npm.js'))
.pipe(header(banner, { pkg : pkg } ))
.pipe(footer("\nmodule.exports = Hermite_class;\n"))
.pipe(gulp.dest('dist'));
});
//list all jobs
gulp.task(
'default',
gulp.series('clean', gulp.parallel('scripts-browser', 'scripts-npm'))
);