-
-
Save mohammedmatar/65235e4a3c4382df6b017ea2a017568d to your computer and use it in GitHub Desktop.
Brotli compression with Angular CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const brotli = require('brotli') | |
const fs = require('fs') | |
const brotliSettings = { | |
extension: 'br', | |
skipLarger: true, | |
mode: 1, // 0 = generic, 1 = text, 2 = font (WOFF2) | |
quality: 10, // 0 - 11, | |
lgwin: 12 // default | |
} | |
fs.readdirSync('dist/').forEach(file => { | |
if (file.endsWith('.js') || file.endsWith('.css') || file.endsWith('.html')) { | |
const result = brotli.compress(fs.readFileSync('dist/' + file), brotliSettings) | |
fs.writeFileSync('dist/' + file + '.br', result) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-ng-cli-app", | |
"scripts": { | |
"build-prod": "ng build --prod && node compress.js" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment