This repository has been archived by the owner on Oct 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
78 lines (70 loc) · 1.9 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
const gulp = require('gulp');
const rollup = require('gulp-rollup');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const less = require('gulp-less');
const bump = require('gulp-bump');
const inline_recources = require('./scripts/inline-resources');
// @ts-ignore
const VERSION = require('./package.json').version;
const paths = {
build: './.ng_build',
lib: './.lib'
};
gulp.task('copy-sources', copySources);
gulp.task('inline-resources', copyResources);
// @ts-ignore
gulp.task('bundle', bundleUmd);
gulp.task('bump', bumpVersions);
function bumpVersions() {
gulp.src([ './package.json'], {base: './'})
.pipe(bump({
version: VERSION
}))
.pipe(gulp.dest('./'));
}
function copySources() {
gulp.src('./lib/**/*')
.pipe(gulp.dest(paths.build))
.on('end', replaceLessWithCSS)
;
}
function replaceLessWithCSS() {
gulp.src(`${paths.build}/**/*.ts`)
.pipe(replace('.less', '.css'))
.pipe(gulp.dest(paths.build))
.on('end', compileLess);
}
function compileLess() {
gulp.src([
`${paths.build}/**/*.less`
])
.pipe(less())
.pipe(gulp.dest(paths.build));
}
function copyResources() {
gulp.src([
`./LICENSE`,
`./README.md`,
`./rollup.config.js`,
`./package.json`,
`${paths.build}/**/*.html`,
`${paths.build}/**/*.css`,
`${paths.build}/**/*.less`
])
.pipe(gulp.dest(paths.lib))
.on('end', () => inline_recources(paths.lib));
}
function bundleUmd() {
bundle(`${paths.lib}/`);
}
function bundle(path) {
const config = require(path + 'rollup.config.js');
gulp.src(path + `**/*.js`)
.pipe(rollup(Object.assign({}, config, {
name: config.name,
input: `${path}index.js`
})))
.pipe(rename(config.output))
.pipe(gulp.dest(`${path}bundles`));
}