forked from ionic-team/ionic-conference-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(): Update app and tabs (ionic-team#709)
* chore() * chore(): update to new setup * chore(): updater after review * chore(): ignore .firebase * chore()
- Loading branch information
1 parent
5c6fc9c
commit cbab4a2
Showing
41 changed files
with
820 additions
and
477 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"projects": { | ||
"default": "ionic-ng-conf-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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ log.txt | |
*.sublime-workspace | ||
.vscode/ | ||
npm-debug.log* | ||
|
||
.firebase/ | ||
.idea/ | ||
.sourcemaps/ | ||
.sass-cache/ | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"hosting": { | ||
"public": "www", | ||
"ignore": [ | ||
"firebase.json", | ||
"**/.*", | ||
"**/node_modules/**" | ||
], | ||
"rewrites": [ | ||
{ | ||
"source": "**", | ||
"destination": "/index.html" | ||
} | ||
], | ||
|
||
"headers": [ | ||
{ | ||
"source": "ngsw-worker.js", | ||
"headers": [ | ||
{ | ||
"key": "Cache-Control", | ||
"value": "no-cache" | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "/", | ||
"headers": [ | ||
{ | ||
"key": "Link", | ||
"value": | ||
"</7.04e49d8eb2fb82393356.js>;rel=preload;as=script,</22.773fbd127d26d4c1e015.js>;rel=preload;as=script,</styles.e4f9b9cdb0cb41a11857.css>;rel=preload;as=style,</runtime.ba232fdef3c9f55aade8.js>;rel=preload;as=script,</polyfills.37712cc894258bf74805.js>;rel=preload;as=script,</main.86732874fcbdf4017d73.js>;rel=preload;as=script,</common.9fdf717d041c0c02bda2.js>;rel=preload;as=script,</179.5fa7823ea707880964e0.js>;rel=preload;as=script,</147.6133d0626a4e6b441c55.js>;rel=preload;as=script,</117.3af3b84bd416f1ef5fe2.js>;rel=preload;as=script,</71.d35160c68098cb9fe3e1.js>;rel=preload;as=script,</165.85e625351a45146a08d3.js>;rel=preload;as=script,</49.665874afb4763feebc7f.js>;rel=preload;as=script,</104.4ca9b1528699c41ec4ff.js>;rel=preload;as=script,</5.1af48c97cf8873405b97.js>;rel=preload;as=script,</145.aef674125cbb0dfe824d.js>;rel=preload;as=script,</121.7677893567365a5cf2a6.js>;rel=preload;as=script,</assets/img/ica-slidebox-img-1.png>;rel=preload;as=script,</assets/img/ica-slidebox-img-2.png>;rel=preload;as=script,</assets/img/ica-slidebox-img-3.png>;rel=preload;as=script,</assets/img/ica-slidebox-img-4.png>;rel=preload;as=script,</6.ba790a199f354956bcb5.js>;rel=preload;as=script," | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env node | ||
const puppeteer = require('puppeteer'); | ||
const fs = require('fs'); | ||
const args = process.argv.slice(2); | ||
const host = args[0] || 'http://127.0.0.1:8080'; | ||
const indexMatches = [ | ||
'.gz', | ||
'.map', | ||
'3rdpartylicenses.txt', | ||
'ngsw-manifest.json', | ||
'ngsw.json', | ||
'worker-basic.min.js', | ||
'ngsw-worker.js', | ||
'favicon', | ||
'index.html', | ||
'manifest.webmanifest', | ||
'.svg' | ||
]; | ||
let results = ''; | ||
async function main(){ | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
|
||
page.on('console', msg => console.log(msg.text())); | ||
|
||
console.log('Page: loaded'); | ||
await page.goto(host); | ||
|
||
const allRequests = new Map(); | ||
page.on('request', req => { | ||
allRequests.set(req.url(), req); | ||
}); | ||
|
||
await page.reload({ waitUntil: 'networkidle0' }); | ||
|
||
Array.from(allRequests.values()).forEach(req => { | ||
const url = req.url(); | ||
|
||
// filter out urls that match these extensions | ||
for (const exlude of indexMatches) { | ||
if (url.indexOf(exlude) != -1) { | ||
return false; | ||
} | ||
} | ||
// if external, dont worry about it for now | ||
if (url.indexOf(host) === -1) return false; | ||
|
||
// Format the url to remove the host | ||
const formatted = url.replace(`${host}/`, ''); | ||
// if it's an empty string, just ignore it | ||
if (!formatted) return false; | ||
|
||
let type = url.substr(-3) == 'css' ? 'style' : 'script'; | ||
results += `</${formatted}>;rel=preload;as=${type},`; | ||
}); | ||
|
||
await browser.close(); | ||
updateWith(results); | ||
}; | ||
function updateWith(result) { | ||
fs.readFile('firebase.json', 'utf8', function(err, data) { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
let re = /("headers":\s*\[\s*{\s*"key":\s*"Link",\s*"value":\s*")(.*)("\s*}\s*\])/gm; | ||
if (re.exec(data)) { | ||
let newConfig = data.replace(re, `$1${result}$3`); | ||
fs.writeFile('firebase.json', newConfig, 'utf8', function(err) { | ||
if (err) return console.log(err); | ||
console.log('firebase.json updated successfully.'); | ||
}); | ||
} else { | ||
console.log("Couldn't find a valid firebase config to update."); | ||
return; | ||
} | ||
}); | ||
} | ||
main(); |
Oops, something went wrong.