From 06edf42203b787393c8f2f9ad0a3a9d1bef7c766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Teixeira?= Date: Sat, 4 Mar 2017 22:25:52 +0000 Subject: [PATCH] Add option to define if sourcemaps should be generated fixes #42 --- lib/service-worker.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/service-worker.js b/lib/service-worker.js index f2282bb..0a7555c 100644 --- a/lib/service-worker.js +++ b/lib/service-worker.js @@ -22,6 +22,7 @@ var BroccoliServiceWorker = function BroccoliServiceWorker(inTree, options) { this.cacheOnlyURLs = options.cacheOnlyURLs || []; this.fastestURLs = options.fastestURLs || []; this.debug = options.debug || false; + this.sourcemaps = options.sourcemaps || this.debug; this.networkFirstURLs = options.networkFirstURLs || options.dynamicCache || []; this.excludePaths = options.excludePaths || ['tests/*']; this.fallback = options.fallback || []; @@ -50,6 +51,7 @@ BroccoliServiceWorker.prototype.write = function(readTree, destDir) { var cacheFirstURLs = this.cacheFirstURLs; var cacheOnlyURLs = this.cacheOnlyURLs; var debug = this.debug; + var sourcemaps = this.sourcemaps; var networkFirstURLs = this.networkFirstURLs; var fallback = this.fallback; var rootURL = this.rootURL; @@ -133,7 +135,7 @@ BroccoliServiceWorker.prototype.write = function(readTree, destDir) { lines.push(getFileContents('log-debug.js')); fs.writeFileSync(path.join(destDir, serviceWorkerFile), lines.join("\n")); fs.writeFileSync(path.join(destDir, toolboxLocation), fs.readFileSync(swToolboxFile)); - if (debug) { + if (sourcemaps) { fs.writeFileSync(path.join(destDir, 'sw-toolbox.js.map'), fs.readFileSync(swToolboxMapFile)); } });