aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/build/workbox.js
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-09-10 22:11:26 -0700
committerzotlabs <mike@macgirvin.com>2018-09-10 22:11:26 -0700
commitadc164b825c3b9e322921f2da9d1baf178b04cd3 (patch)
treefa5e805e53e7661ad936873e1a66017ad9dcd6a9 /vendor/twbs/bootstrap/build/workbox.js
parentbe3b6304742a6c39d73674b1f7422c029e7cd804 (diff)
parentc6abe87ec2e08fc38ff9c505ac2000d52d45c228 (diff)
downloadvolse-hubzilla-adc164b825c3b9e322921f2da9d1baf178b04cd3.tar.gz
volse-hubzilla-adc164b825c3b9e322921f2da9d1baf178b04cd3.tar.bz2
volse-hubzilla-adc164b825c3b9e322921f2da9d1baf178b04cd3.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into xdev_merge
Diffstat (limited to 'vendor/twbs/bootstrap/build/workbox.js')
-rw-r--r--vendor/twbs/bootstrap/build/workbox.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/twbs/bootstrap/build/workbox.js b/vendor/twbs/bootstrap/build/workbox.js
new file mode 100644
index 000000000..3a7ba450a
--- /dev/null
+++ b/vendor/twbs/bootstrap/build/workbox.js
@@ -0,0 +1,58 @@
+/*!
+ * Script to generate our docs service worker.
+ * Copyright 2017-2018 The Bootstrap Authors
+ * Copyright 2017-2018 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ */
+
+'use strict'
+
+const fs = require('fs')
+const path = require('path')
+const swBuild = require('workbox-build')
+const config = require('./workbox.config.json')
+
+const buildPrefix = '_gh_pages/'
+
+const workboxSWSrcPath = require.resolve('workbox-sw')
+const wbFileName = path.basename(workboxSWSrcPath)
+const workboxSWDestPath = `${buildPrefix}docs/4.1/assets/js/vendor/${wbFileName}`
+const workboxSWSrcMapPath = `${workboxSWSrcPath}.map`
+const workboxSWDestMapPath = `${workboxSWDestPath}.map`
+
+fs.createReadStream(workboxSWSrcPath).pipe(fs.createWriteStream(workboxSWDestPath))
+fs.createReadStream(workboxSWSrcMapPath).pipe(fs.createWriteStream(workboxSWDestMapPath))
+
+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: []
+ }
+}
+
+config.manifestTransforms = [updateUrl]
+
+swBuild.injectManifest(config).then(({
+ count,
+ size
+}) => {
+ const wbSwRegex = /{fileName}/g
+ fs.readFile(config.swDest, 'utf8', (err, data) => {
+ if (err) {
+ throw err
+ }
+ const swFileContents = data.replace(wbSwRegex, wbFileName)
+ fs.writeFile(config.swDest, swFileContents, () => {
+ console.log(`Pre-cache Manifest generated. Pre-cached ${count} files, totalling ${size} bytes.`)
+ })
+ })
+}).catch((error) => {
+ console.error(`Something went wrong: ${error}`)
+})