Skip to content

Commit

Permalink
Merge pull request #117 from BBVAEngineering/bugfix-default-options
Browse files Browse the repository at this point in the history
Allow override default settings
  • Loading branch information
adrigzr authored Feb 2, 2022
2 parents 47d442f + c3df91b commit 2fed668
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.eslintcache
*.html
*.hbs
CHANGELOG.md

# ember-try
/.node_modules.ember-try/
Expand Down
41 changes: 24 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ module.exports = {
isDevelopingAddon: () => true,

config(env, baseConfig) {
const workboxOptions = (this.app && this.app.options.workbox) || {};
const emberCliWorkboxOptions = baseConfig['ember-cli-workbox'];
const options = emberCliWorkboxOptions || {};
const appOptions =
(this.app && this.app.options['ember-cli-workbox']) || {};
const projectName = (baseConfig.APP && baseConfig.APP.name) || 'app';
let workboxOptions = (this.app && this.app.options.workbox) || {};
let options = emberCliWorkboxOptions || {};

Object.assign(workboxOptions, {
swDest: 'sw.js',
globDirectory: './',
globPatterns: [
'**/*.{json,css,js,png,svg,eot,ttf,woff,jpg,gif,ico,xml,html,txt}',
],
skipWaiting: false,
clientsClaim: false,
cacheId: projectName,
});
workboxOptions = Object.assign(
{
swDest: 'sw.js',
globDirectory: './',
globPatterns: [
'**/*.{json,css,js,png,svg,eot,ttf,woff,jpg,gif,ico,xml,html,txt}',
],
skipWaiting: false,
clientsClaim: false,
cacheId: projectName,
},
workboxOptions
);

env = env || process.env.EMBER_ENV;

Expand All @@ -37,11 +40,15 @@ module.exports = {

const isProdBuild = Boolean(env.match('prod'));

Object.assign(options, appOptions, {
enabled: isProdBuild,
debug: !isProdBuild,
importScriptsGlobPatterns: ['assets/service-workers/*.js'],
});
options = Object.assign(
{
enabled: isProdBuild,
debug: !isProdBuild,
importScriptsGlobPatterns: ['assets/service-workers/*.js'],
},
options,
appOptions
);

this._options = options;
this.workboxOptions = workboxOptions;
Expand Down

0 comments on commit 2fed668

Please sign in to comment.