Skip to content

Commit

Permalink
Merge pull request #30 from andrei-zhidkov/root-url
Browse files Browse the repository at this point in the history
Add rootURL option
  • Loading branch information
jkleinsc authored Aug 17, 2016
2 parents 3632e6d + e24f55c commit 1c482b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/ember-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = {
var defaultOptions = {
enabled: this.app.env === 'production',
excludePaths: ['test.*','robots.txt'],
precacheURLs: []
precacheURLs: [],
rootURL: appOptions.rootURL || appOptions.baseURL
};

for (var option in defaultOptions) {
Expand Down
4 changes: 3 additions & 1 deletion lib/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var BroccoliServiceWorker = function BroccoliServiceWorker(inTree, options) {
this.networkFirstURLs = options.networkFirstURLs || options.dynamicCache || [];
this.excludePaths = options.excludePaths || ['tests/*'];
this.fallback = options.fallback || [];
this.rootURL = options.rootURL || '/';
this.precacheURLs = options.precacheURLs || [];
if (options.includeRegistration === false) {
this.includeRegistration = false;
Expand All @@ -50,6 +51,7 @@ BroccoliServiceWorker.prototype.write = function(readTree, destDir) {
var debug = this.debug;
var networkFirstURLs = this.networkFirstURLs;
var fallback = this.fallback;
var rootURL = this.rootURL;
var fastestURLs = this.fastestURLs;
var precacheURLs = this.precacheURLs;
var serviceWorkerFile = this.serviceWorkerFile;
Expand All @@ -70,7 +72,7 @@ BroccoliServiceWorker.prototype.write = function(readTree, destDir) {
lines.push("toolbox.options.debug = true;");
}
lines.push("var urlsToPrefetch = [");
lines.push(" '/',");
lines.push(" '"+rootURL+"',");
getFilesRecursively(srcDir, [ "**/*" ]).forEach(function (file, idx, array) {
lines.push(createArrayLine(' '+JSON.stringify(file), idx, array.length));
});
Expand Down

0 comments on commit 1c482b6

Please sign in to comment.