-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
72 lines (64 loc) · 1.97 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
const gulp = require('gulp')
const plumber = require('gulp-plumber')
const insert = require('gulp-insert')
const ts = require('gulp-typescript')
const webpack = require('webpack-stream')
const webpackConfig = require('./webpack.config.js')
const tsProject1 = ts.createProject('tsconfig.json')
const tsProject2 = ts.createProject('tsconfig.json')
const tsProject3 = ts.createProject('tsconfig.json')
const libraryClientWebpackConfig = webpackConfig('library')
const cliClientWebpackConfig = webpackConfig('client')
const serverWebpackConfig = webpackConfig('server')
// Client Library
gulp.task('build-library-client', function () {
return gulp
.src(['./src/client/**/*.ts', '!./src/client/**/*.spec.ts'])
.pipe(plumber())
.pipe(tsProject1())
.pipe(webpack(libraryClientWebpackConfig))
.pipe(gulp.dest('./dist'))
})
// Client CLI
gulp.task('transpile-cli-client', function () {
return gulp
.src(['./src/client/**/*.ts', '!./src/client/**/*.spec.ts'])
.pipe(plumber())
.pipe(tsProject2())
.pipe(webpack(cliClientWebpackConfig))
.pipe(gulp.dest('./bin'))
})
gulp.task('index-cli-client', function () {
return gulp
.src('./bin/txr-client')
.pipe(insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(gulp.dest('./bin'))
})
// Server CLI
gulp.task('transpile-cli-server', function () {
return gulp
.src(['./src/server/**/*.ts', '!./src/server/**/*.spec.ts'])
.pipe(plumber())
.pipe(tsProject3())
.pipe(webpack(serverWebpackConfig))
.pipe(gulp.dest('./bin'))
})
gulp.task('index-cli-server', function () {
return gulp
.src('./bin/txr-server')
.pipe(insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(gulp.dest('./bin'))
})
// Entry points
gulp.task(
'build-cli-client',
gulp.series('transpile-cli-client', 'index-cli-client')
)
gulp.task(
'build-cli-server',
gulp.series('transpile-cli-server', 'index-cli-server')
)
gulp.task(
'build',
gulp.parallel('build-library-client', 'build-cli-client', 'build-cli-server')
)