-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
76 lines (62 loc) · 1.95 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
const path = require('path');
var gulp = require('gulp');
var concat = require('gulp-concat');
var concatCss = require('gulp-concat-css');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var uglifyCss = require('gulp-uglifycss');
var htmlmin = require('gulp-htmlmin');
var inlinesource = require('gulp-inline-source');
var run = require('gulp-run-command').default;
var del = require("del");
const headerComment = require('gulp-header-comment');
var srcDir = "src/"
var distDir = "dist/"
//VARIABLES
var cmpDistTmpFile = "build/sdk.js";
var jsFiles = ['./lib/*.js', '../node_modules/muffin/dist/muffin.min.js'];
var jsDest = '/';
var htmlFiles = ['index.src.html'];
var htmlDest = '.';
var getSrcDirs = (_dirs) => {
return _dirs.map((_dir) => {
return path.join(srcDir, _dir);
});
}
var getDestDir = (_dir) => {
return path.join(distDir, _dir);
}
gulp.task('buildes6js', run("./node_modules/.bin/rollup -c"));
gulp.task('buildJs', function () {
return gulp.src([].concat(getSrcDirs(jsFiles), cmpDistTmpFile))
.pipe(concat('sdk.js'))
// .pipe(gulp.dest(jsDest))
.pipe(rename('sdk.min.js'))
// .pipe(uglify())
.pipe(headerComment(`
License: <%= pkg.license %>
Generated on <%= moment().format('YYYY') %>
Author: <%= _.capitalize(pkg.author) %>
Version: <%= pkg.version %>
`))
.pipe(gulp.dest(getDestDir(jsDest)));
});
gulp.task('buildHtml', () => {
var options = {
compress: false,
attribute: 'inline-src'
};
return gulp.src(getSrcDirs(htmlFiles))
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(rename('index.html'))
.pipe(gulp.dest(getDestDir(htmlDest)))
.pipe(inlinesource(options))
.pipe(gulp.dest(getDestDir(htmlDest)));
});
sanitise = () => {
del('_cmps_tmp', {force: true})
}
gulp.task('buildAll', gulp.series('buildes6js', 'buildJs', function done(done) {
sanitise();
done();
}));