0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-17 09:52:29 +01:00

Update to workbox 3.0 & fix breaking changes

This commit is contained in:
Michael 2018-03-16 20:46:58 +00:00 committed by XhmikosR
parent 1615a76f83
commit 7dc41e299b
4 changed files with 180 additions and 59 deletions

View File

@ -16,17 +16,26 @@ const workboxSWDestMapPath = `${workboxSWDestPath}.map`
fs.createReadStream(workboxSWSrcPath).pipe(fs.createWriteStream(workboxSWDestPath))
fs.createReadStream(workboxSWSrcMapPath).pipe(fs.createWriteStream(workboxSWDestMapPath))
const updateUrl = (manifestEntries) => manifestEntries.map((entry) => {
if (entry.url.startsWith(buildPrefix)) {
const regex = new RegExp(buildPrefix, 'g')
entry.url = entry.url.replace(regex, '')
const updateUrl = (manifestEntries) => {
const manifest = manifestEntries.map((entry) => {
if (entry.url.startsWith(buildPrefix)) {
const regex = new RegExp(buildPrefix, 'g')
entry.url = entry.url.replace(regex, '')
}
return entry
})
return {
manifest,
warnings: []
}
return entry
})
}
config.manifestTransforms = [updateUrl]
swBuild.injectManifest(config).then(() => {
swBuild.injectManifest(config).then(({
count,
size
}) => {
const wbSwRegex = /{fileName}/g
fs.readFile(config.swDest, 'utf8', (err, data) => {
if (err) {
@ -34,7 +43,9 @@ swBuild.injectManifest(config).then(() => {
}
const swFileContents = data.replace(wbSwRegex, wbFileName)
fs.writeFile(config.swDest, swFileContents, () => {
console.log('Pre-cache Manifest generated.')
console.log('Pre-cache Manifest generated.', `Pre-cached ${count} files, totalling ${size} bytes.`)
})
})
}).catch((error) => {
console.error(`Something went wrong: ${error}`)
})

208
package-lock.json generated
View File

@ -2436,6 +2436,15 @@
"integrity": "sha512-7B1ilBwtYSbetCgTY1NJFg+gVpestg0fdA1MhC1Vs4ssyfSXnCAjFr+QcQM9/RedXC0EaUx1sG8Smgw2VfgKEg==",
"dev": true
},
"common-tags": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.7.2.tgz",
"integrity": "sha512-joj9ZlUOjCrwdbmiLqafeUSgkUM74NqhLsZtSqDmhKudaIY197zTrb8JMl31fMnCUuxwFT23eC/oWvrZzDLRJQ==",
"dev": true,
"requires": {
"babel-runtime": "6.26.0"
}
},
"compare-versions": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.1.0.tgz",
@ -6739,6 +6748,23 @@
"integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=",
"dev": true
},
"isemail": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/isemail/-/isemail-3.1.1.tgz",
"integrity": "sha512-mVjAjvdPkpwXW61agT2E9AkGoegZO7SdJGCezWwxnETL58f5KwJ4vSVAMBUL5idL6rTlYAIGkX3n4suiviMLNw==",
"dev": true,
"requires": {
"punycode": "2.1.0"
},
"dependencies": {
"punycode": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz",
"integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=",
"dev": true
}
}
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -6875,6 +6901,17 @@
"integrity": "sha1-2t2e8BkkvHKLA/L3l5vb1i96Kqo=",
"dev": true
},
"joi": {
"version": "11.4.0",
"resolved": "https://registry.npmjs.org/joi/-/joi-11.4.0.tgz",
"integrity": "sha512-O7Uw+w/zEWgbL6OcHbyACKSj0PkQeUgmehdoXVSxt92QFCq4+1390Rwh5moI2K/OgC7D8RHRZqHZxT2husMJHA==",
"dev": true,
"requires": {
"hoek": "4.2.1",
"isemail": "3.1.1",
"topo": "2.0.2"
}
},
"js-base64": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.3.tgz",
@ -10497,6 +10534,12 @@
"integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=",
"dev": true
},
"pretty-bytes": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz",
"integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=",
"dev": true
},
"pretty-hrtime": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz",
@ -13322,6 +13365,15 @@
}
}
},
"topo": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/topo/-/topo-2.0.2.tgz",
"integrity": "sha1-zVYVdSU5BXwNwEkaYhw7xvvh0YI=",
"dev": true,
"requires": {
"hoek": "4.2.1"
}
},
"touch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
@ -14051,71 +14103,129 @@
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"dev": true
},
"workbox-build": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/workbox-build/-/workbox-build-2.1.3.tgz",
"integrity": "sha512-QuFHYsRFR/ZhWRxU/VMAXUSfCIgol1iRgJ22mV1bM9GGRycW/VqbyhIcY95GjX0V8rNu+8d65t48xjnrtf9hqw==",
"workbox-background-sync": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-3.0.0.tgz",
"integrity": "sha512-tW1tFz41fFDbSEOErYU1EKxDox72qozVxKsl8jbjpvtNvAn4ml2XIIs0jcmtpDu5uNuBP9wXt/5Vytw6F7IkTg==",
"dev": true,
"requires": {
"chalk": "1.1.3",
"fs-extra": "3.0.1",
"workbox-core": "3.0.0"
}
},
"workbox-broadcast-cache-update": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-broadcast-cache-update/-/workbox-broadcast-cache-update-3.0.0.tgz",
"integrity": "sha512-CjJDfN5Qo2SfVEBZb5SVlO6I1QLi/i4okdqnfIvFiNq+oJYa+8JjgeXG7z2Z9xBd9ac22Fpy5Mg/fo33YrL6Wg==",
"dev": true,
"requires": {
"workbox-core": "3.0.0"
}
},
"workbox-build": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-build/-/workbox-build-3.0.0.tgz",
"integrity": "sha512-/LGWEyERFZNp/+mNSl4m9BYNfNc0LAkSamnqR/jWr9t31Bm913mhzDPvYWE7ZsjdvAHidkuX1nOOfPFyk+jJdA==",
"dev": true,
"requires": {
"babel-runtime": "6.26.0",
"common-tags": "1.7.2",
"fs-extra": "4.0.3",
"glob": "7.1.2",
"joi": "11.4.0",
"lodash.template": "4.4.0",
"mkdirp": "0.5.1",
"workbox-sw": "2.1.3"
"pretty-bytes": "4.0.2",
"workbox-background-sync": "3.0.0",
"workbox-broadcast-cache-update": "3.0.0",
"workbox-cache-expiration": "3.0.0",
"workbox-cacheable-response": "3.0.0",
"workbox-core": "3.0.0",
"workbox-google-analytics": "3.0.0",
"workbox-precaching": "3.0.0",
"workbox-routing": "3.0.0",
"workbox-strategies": "3.0.0",
"workbox-sw": "3.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
"dev": true
},
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"dev": true,
"requires": {
"ansi-styles": "2.2.1",
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1",
"supports-color": "2.0.0"
}
},
"fs-extra": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz",
"integrity": "sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE=",
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz",
"integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==",
"dev": true,
"requires": {
"graceful-fs": "4.1.11",
"jsonfile": "3.0.1",
"jsonfile": "4.0.0",
"universalify": "0.1.1"
}
},
"jsonfile": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz",
"integrity": "sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=",
"dev": true,
"requires": {
"graceful-fs": "4.1.11"
}
},
"supports-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"dev": true
}
}
},
"workbox-cache-expiration": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-cache-expiration/-/workbox-cache-expiration-3.0.0.tgz",
"integrity": "sha512-jvkWxWvI3fa9pUqt/UN8oEPXemXynLLMjCZCmds2ZHuTMfwAw3qeniw9HxGud0hA8LBZDibcTC/qKk7E1myo3A==",
"dev": true,
"requires": {
"workbox-core": "3.0.0"
}
},
"workbox-cacheable-response": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-cacheable-response/-/workbox-cacheable-response-3.0.0.tgz",
"integrity": "sha512-6jGcLSngb5QUdwk5eMoD8YYHcoH7jPi9Bz94C0n9dvPD6N+ex2H/dg2aHvltmjes9iDTI++Ac3d2EoDrsHrQoQ==",
"dev": true,
"requires": {
"workbox-core": "3.0.0"
}
},
"workbox-core": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-3.0.0.tgz",
"integrity": "sha512-R4ZJ1dcllIaiJ082qjWHZTYfVUQ/th7liNOmWU1yPoK1NwUxqJRRN3XCdw/yrtoeO//RCkTlrCcTteHUYFZ/fg==",
"dev": true
},
"workbox-google-analytics": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-google-analytics/-/workbox-google-analytics-3.0.0.tgz",
"integrity": "sha512-fyfY2hpK/tLV5xY6iagd4I+PhHtHKC3V5zMqaMDvlBkow79WyUFvHRXM4rk8YEitL2G66V6a8fzDS79tM/BqUg==",
"dev": true,
"requires": {
"workbox-background-sync": "3.0.0",
"workbox-core": "3.0.0",
"workbox-routing": "3.0.0",
"workbox-strategies": "3.0.0"
}
},
"workbox-precaching": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-precaching/-/workbox-precaching-3.0.0.tgz",
"integrity": "sha512-EVlbGmzc18SiuRNymswSjg5jqVysOrbvMtav4FhF/3+oagCgvgJrBgmsymJucPzdH76KlP2GHvHEUx0T1TkFhA==",
"dev": true,
"requires": {
"workbox-core": "3.0.0"
}
},
"workbox-routing": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-routing/-/workbox-routing-3.0.0.tgz",
"integrity": "sha512-1IlKk8g7GRGERX2T8T3pC+YLt9xnv83GjizJCmzAlVqJNG+BcGGWqRegb746Ukwp436BxzNiLmGY7+/yZ879uw==",
"dev": true,
"requires": {
"workbox-core": "3.0.0"
}
},
"workbox-strategies": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-strategies/-/workbox-strategies-3.0.0.tgz",
"integrity": "sha512-wH4BrwcYN5hfSmzpeMDGFyc2veCbhhj9gQumWm/N+1QyTxPDu7zOppWuKNK9btWdqPV/nqv/AxTFhJ/+Cxth7w==",
"dev": true,
"requires": {
"workbox-core": "3.0.0"
}
},
"workbox-sw": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/workbox-sw/-/workbox-sw-2.1.3.tgz",
"integrity": "sha512-ZwT1Igbd9gAbn0U8gqachKTCGisS9WFM2j85FvI5K88FfNJ5OlYrDksXQmACRyvX59bwXIo/CGDU7FSsMtRVhw==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/workbox-sw/-/workbox-sw-3.0.0.tgz",
"integrity": "sha512-HG/V0EyqYrLyGvjPWjqfAFfc/raN30+wuOUQN0Rh0/lCei4wogqaBnvjS4bciNd6jCf6b6zhgWLsqnVJxK63fw==",
"dev": true
},
"wrap-ansi": {

View File

@ -128,7 +128,7 @@
"stylelint-scss": "^2.5.0",
"uglify-js": "^3.3.14",
"vnu-jar": "^17.11.1",
"workbox-build": "^2.1.3"
"workbox-build": "^3.0.0"
},
"engines": {
"node": ">=6"

2
sw.js
View File

@ -1,4 +1,4 @@
self.importScripts('/assets/js/vendor/{fileName}')
const workboxSW = new self.WorkboxSW()
workboxSW.precache([])
workboxSW.precaching.precacheAndRoute([])