Created
March 20, 2017 16:25
-
-
Save StephenFluin/9eb33ed139e730d3aa62a78aab818f2a to your computer and use it in GitHub Desktop.
NodeJS Command to generate firebase compatible headers for your Angular app
This file contains 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
fs = require('fs'); | |
fs.readdir('dist/', (err, files) => { | |
files = files.filter(file => { | |
if(file.indexOf('.gz') != -1) { | |
return false; | |
} | |
if(file.indexOf('favicon') != -1) { | |
return false | |
} | |
if(file.indexOf('index.html') != -1) { | |
return false; | |
} | |
if(fs.lstatSync(`dist/${file}`).isDirectory()) { | |
return false; | |
} | |
if(file.indexOf('.bundle.') != -1 || file.indexOf('.chunk.')) { | |
return true; | |
} else { | |
return false; | |
} | |
}) | |
let result = ''; | |
for(let file of files) { | |
let type; | |
if(file.substr(-3) == "css") { | |
type = 'style'; | |
} else { | |
type = 'script'; | |
} | |
result += `</${file}>;rel=preload;as=${type},` | |
} | |
console.log(result); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment