@@ -19,6 +19,11 @@ const corePkgs = ['sanity', '@sanity/vision'] as const
19
19
20
20
const appVersion = 'v1'
21
21
22
+ const mimeTypes : Record < string , string | undefined > = {
23
+ '.mjs' : 'application/javascript' ,
24
+ '.map' : 'application/json' ,
25
+ }
26
+
22
27
/**
23
28
* Replaces all slashes with double underscores
24
29
*/
@@ -60,16 +65,22 @@ async function copyPackages() {
60
65
packageVersions . set ( pkg , version )
61
66
62
67
// Convert slashes to double underscores
63
- // Needed for `@sanity/vision`
68
+ // Needed for `@sanity/vision` and other scoped packages
64
69
const cleanDir = cleanDirName ( pkg )
65
70
66
71
for await ( const filePath of getFiles ( `packages/${ pkg } /dist` ) ) {
67
72
try {
68
73
const fileName = path . basename ( filePath )
74
+ const ext = path . extname ( fileName )
75
+ const contentType = mimeTypes [ ext ]
76
+ if ( ! contentType ) {
77
+ throw new Error ( `Unknown content type for file ${ filePath } ` )
78
+ }
79
+
69
80
const options : UploadOptions = {
70
81
destination : `modules/${ appVersion } /${ cleanDir } /${ version } /bare/${ fileName } ` ,
71
82
gzip : true ,
72
- contentType : 'application/javascript' ,
83
+ contentType,
73
84
metadata : {
74
85
// 1 year cache
75
86
cacheControl : 'public, max-age=31536000, immutable' ,
0 commit comments