Skip to content

Instantly share code, notes, and snippets.

@StephenFluin
Created March 20, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephenFluin/9eb33ed139e730d3aa62a78aab818f2a to your computer and use it in GitHub Desktop.
Save StephenFluin/9eb33ed139e730d3aa62a78aab818f2a to your computer and use it in GitHub Desktop.
NodeJS Command to generate firebase compatible headers for your Angular app
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