Skip to content

Commit 4c01658

Browse files
committed
fix: oss deployment
1 parent 0e6b52a commit 4c01658

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/deploy-to-oss.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
require('dotenv').config()
22

3-
const { readdir } = require('fs').promises
43
const path = require('path')
54
const OSS = require('ali-oss')
65
const consola = require('consola')
76

7+
const files = require('../.nuxt/dist/server/client.manifest.json').all.filter(file => !file.startsWith('.'))
8+
89
;(async () => {
910
const cfg = {
1011
accessKeyId: process.env.ALI_OSS_ACCESS_KEY_ID,
@@ -15,9 +16,9 @@ const consola = require('consola')
1516
if (Object.values(cfg).some(x => typeof x !== 'string')) throw new Error('Invalid config')
1617
const store = new OSS(cfg)
1718
const distDir = '.nuxt/dist/client'
18-
for (const file of await readdir(distDir)) {
19+
for (const file of files) {
1920
await store.put(path.join(process.env.ALI_OSS_ASSETS_PREFIX || '', file), path.join(distDir, file), {
20-
headers: { 'Cache-Control': 'public, max-age=31536000' },
21+
headers: file === 'LICENSES' ? {} : { 'Cache-Control': 'public, max-age=31536000, immutable' },
2122
})
2223
}
2324
})().catch(e => {

0 commit comments

Comments
 (0)