-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
51 lines (44 loc) · 1.07 KB
/
gulpfile.js
File metadata and controls
51 lines (44 loc) · 1.07 KB
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
const gulp = require('gulp')
const ejs = require('gulp-ejs')
const rename = require('gulp-rename')
const rimraf = require('gulp-rimraf')
const prettier = require('gulp-prettier')
const { camelCase } = require('camel-case')
const pkgConfig = require('./package')
const ejsConfig = require('./src/pluginConfig')
/**
* 移除 dist 文件夹
*/
gulp.task('clean', () => {
return gulp.src('./dist', { allowEmpty: true })
.pipe(rimraf())
})
/**
* 渲染 ejs 文件
*/
gulp.task('render-ejs', () => {
return gulp.src('./src/**/*.ejs')
.pipe(ejs({
pluginName: camelCase(pkgConfig.name),
pkg: pkgConfig,
data: ejsConfig,
}))
.pipe(rename({
extname: '',
}))
.pipe(prettier({
editorconfig: true,
}))
.pipe(gulp.dest('./dist'))
})
/**
* 拷贝无需渲染的文件
*/
gulp.task('copy', () => {
return gulp.src(['./src/**/*', '!./src/**/*.ejs'])
.pipe(gulp.dest('./dist'))
})
gulp.task('watch', () => {
gulp.watch(['./src/**'], gulp.parallel('render-ejs', 'copy'))
})
gulp.task('default', gulp.parallel('render-ejs', 'copy'))