-
Notifications
You must be signed in to change notification settings - Fork 187
/
writeHeadersJsonTask.js
51 lines (45 loc) · 1.35 KB
/
writeHeadersJsonTask.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
const fs = require('fs')
const glob = require('glob')
const path = require('path')
module.exports = function writeHeadersJson() {
function writeHeadersJson(matchGlob, headersData = {}) {
const files = glob.sync(path.resolve(__dirname, "dist", matchGlob))
files.forEach((f) => {
const headersFilePath = f + '.headersJson'
fs.writeFileSync(headersFilePath, JSON.stringify(headersData))
})
}
function writeHeadersJsonCss() {
const headersData = {
'Content-Type': 'text/css',
'Cache-Control':
'no-transform,public,max-age=31536000,s-maxage=31536000'
}
writeHeadersJson('*.css', headersData)
}
function writeHeadersJsonHtml() {
const headersData = {
'Content-Type': 'text/html; charset=UTF-8',
'Cache-Control': 'no-cache'
}
writeHeadersJson('*.html', headersData)
}
function writeHeadersJsonJs() {
const headersData = {
'Content-Type': 'application/javascript',
'Cache-Control':
'no-transform,public,max-age=31536000,s-maxage=31536000'
}
writeHeadersJson('*.js', headersData)
}
function writeHeadersJsonMisc() {
const headersData = {
'Content-Type': 'image/vnd.microsoft.icon'
}
writeHeadersJson('favicon.ico', headersData)
}
writeHeadersJsonCss();
writeHeadersJsonHtml();
writeHeadersJsonJs();
writeHeadersJsonMisc();
};