This repository has been archived by the owner on Feb 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (65 loc) · 2.11 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
79
const gulp = require('gulp')
const del = require('del')
const webpack = require('webpack-stream')
const ghpages = require('gh-pages')
const shell = require('shelljs')
const babel = require('gulp-babel')
const ts = require('gulp-typescript')
const appRoot = require('app-root-path').toString()
const replace = require('gulp-replace')
const merge = require('merge2')
/**
* Nami 使用 gulp 及 webpack 进行发布构建
*/
var paths = {
nami: {
entry: 'src/index.ts',
ts: 'src/**/*{.ts,.tsx}',
others: ['src/**/*', '!src/**/*{.ts,.tsx}', '!**/{demos,demos/**}'],
},
site: {
entry: 'site/index.tsx',
},
}
gulp.task('clean', function() {
return del(['_site', 'dist', 'dist-es'])
})
gulp.task('nami:es', function() {
const tsProject = ts.createProject('tsconfig.json', {
declaration: true,
})
const tsResult = gulp
.src(paths.nami.ts)
.pipe(replace('__DEV__', 'false'))
.pipe(tsProject())
return merge(tsResult.dts, tsResult.js.pipe(babel()), gulp.src(paths.nami.others)).pipe(
gulp.dest('dist-es/')
)
})
gulp.task('nami:umd', function() {
return gulp
.src(paths.nami.entry)
.pipe(webpack(require('./webpack.config.js')()))
.pipe(gulp.dest('dist/'))
})
gulp.task('site:docs-parser', function(done) {
shell.cd(appRoot)
if (shell.exec('npm run docs-parser').code !== 0) {
throw new Error('docs-parser failed!')
}
done()
})
gulp.task('site:webpack', function() {
return gulp
.src(paths.site.entry)
.pipe(webpack(require('./site/webpack.config.js')({ production: true })))
.pipe(gulp.dest('_site/'))
})
gulp.task('site:gh-pages', function(done) {
ghpages.publish('_site', done)
})
gulp.task('nami:build', gulp.series('nami:umd', 'nami:es'))
gulp.task('site:build', gulp.series('site:docs-parser', 'site:webpack'))
gulp.task('site:publish', gulp.series('site:build', 'site:gh-pages'))
gulp.task('build', gulp.series('clean', gulp.series('nami:build', 'site:build')))
gulp.task('publish', gulp.series('clean', gulp.series('nami:build', 'site:publish')))