gzip and minify json

pull/130777/head^2
Tyler Leonhardt 2021-09-17 09:31:54 -07:00
parent 185cd70071
commit d8d0570244
No known key found for this signature in database
GPG Key ID: 1BC2B6244363E77E
2 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,7 @@ const es = require("event-stream");
const vfs = require("vinyl-fs");
const util = require("../lib/util");
const merge = require("gulp-merge-json");
const gzip = require("gulp-gzip");
const azure = require('gulp-azure-storage');
const root = path.dirname(path.dirname(__dirname));
const commit = util.getVersion(root);
@ -16,6 +17,7 @@ function main() {
return es.merge(vfs.src('out-vscode-min/nls.metadata.json', { base: 'out-vscode-min' }), vfs.src('.build/extensions/**/nls.metadata.json', { base: '.build/extensions' }), vfs.src('.build/extensions/**/nls.metadata.header.json', { base: '.build/extensions' }), vfs.src('.build/extensions/**/package.nls.json', { base: '.build/extensions' }))
.pipe(merge({
fileName: 'combined.nls.metadata.json',
jsonSpace: '',
edit: (parsedJson, file) => {
let key;
if (file.base === 'out-vscode-min') {
@ -64,6 +66,7 @@ function main() {
return { [key]: parsedJson };
},
}))
.pipe(gzip({ append: false }))
.pipe(vfs.dest('./nlsMetadata'))
.pipe(es.through(function (data) {
console.log(`Uploading ${data.path}`);
@ -75,7 +78,11 @@ function main() {
account: process.env.AZURE_STORAGE_ACCOUNT,
key: process.env.AZURE_STORAGE_ACCESS_KEY,
container: 'nlsmetadata',
prefix: commit + '/'
prefix: commit + '/',
contentSettings: {
contentEncoding: 'gzip',
cacheControl: 'max-age=31536000, public'
}
}));
}
main();

View File

@ -11,6 +11,7 @@ import * as Vinyl from 'vinyl';
import * as vfs from 'vinyl-fs';
import * as util from '../lib/util';
import * as merge from 'gulp-merge-json';
import * as gzip from 'gulp-gzip';
const azure = require('gulp-azure-storage');
const root = path.dirname(path.dirname(__dirname));
@ -30,6 +31,7 @@ function main() {
vfs.src('.build/extensions/**/package.nls.json', { base: '.build/extensions' }))
.pipe(merge({
fileName: 'combined.nls.metadata.json',
jsonSpace: '',
edit: (parsedJson, file) => {
let key;
if (file.base === 'out-vscode-min') {
@ -82,6 +84,7 @@ function main() {
return { [key]: parsedJson };
},
}))
.pipe(gzip({ append: false }))
.pipe(vfs.dest('./nlsMetadata'))
.pipe(es.through(function (data: Vinyl) {
console.log(`Uploading ${data.path}`);
@ -93,7 +96,11 @@ function main() {
account: process.env.AZURE_STORAGE_ACCOUNT,
key: process.env.AZURE_STORAGE_ACCESS_KEY,
container: 'nlsmetadata',
prefix: commit + '/'
prefix: commit + '/',
contentSettings: {
contentEncoding: 'gzip',
cacheControl: 'max-age=31536000, public'
}
}));
}