forked from 397909414/eleme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.js
48 lines (45 loc) · 1.18 KB
/
publish.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
const gulp = require('gulp')
const ossSync = require('gulp-oss-sync')
const axios = require('axios')
// 触发服务端部署脚本
gulp.task('server', async () => {
const {data: {message}} = await axios({
method: 'POST',
url: 'https://hongbao.xxooweb.com/publish',
data: {
key: process.env.ELEME_PUBLISH_KEY
}
})
console.log(message)
})
// 静态资源部署到阿里云 OSS
const ossSetting = {
connect: {
region: 'oss-cn-hongkong',
accessKeyId: process.env.ALIOSS_ACCESS_KEY_ID,
accessKeySecret: process.env.ALIOSS_ACCESS_KEY_SECRET,
bucket: 'elmhb'
},
setting: {
dir: '',
noClean: false,
force: true,
quiet: true
},
controls: {
headers: {
'Cache-Control': 'max-age=' + 60 * 60 * 24 * 365 * 10
}
}
}
const ossHtmlSetting = Object.assign({}, ossSetting, {
controls: {
headers: {
'Cache-Control': 'no-cache'
}
}
})
gulp.task('web:res', () => gulp.src(['web/dist/**/*', '!web/dist/index.html']).pipe(ossSync(ossSetting)))
gulp.task('web:html', ['web:res'], () => gulp.src('web/dist/index.html').pipe(ossSync(ossHtmlSetting)))
gulp.task('web', ['web:html'])
gulp.task('default', ['server', 'web'])