From e74239a7a37378776b221cf9c45ac29a413bf30e Mon Sep 17 00:00:00 2001 From: colenso Date: Wed, 16 Mar 2022 16:13:54 +0530 Subject: [PATCH 1/2] feat: add function to manually process app tree --- index.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index cf56bbb..109182c 100644 --- a/index.js +++ b/index.js @@ -58,11 +58,21 @@ module.exports = { } }, - postprocessTree(type, tree) { - if (type !== 'all') { - return tree; + processTree(app, tree) { + let emberCliWorkboxAddon = app.project.addons.find( + ({ name }) => name === 'ember-cli-workbox' + ); + + if (!emberCliWorkboxAddon) { + throw new Error( + "Could not find initialized ember-cli-workbox addon. It must be part of your app's dependencies!" + ); } + return emberCliWorkboxAddon._processTree(tree); + }, + + _processTree(tree) { const workboxFunnel = new BroccoliWorkbox([tree], { options: this._options, workboxOptions: this.workboxOptions, @@ -72,4 +82,12 @@ module.exports = { overwrite: true, }); }, + + postprocessTree(type, tree) { + if (type !== 'all') { + return tree; + } + + this._processTree(tree); + }, }; From 78d5569acd3d909e805a4dc3803ca2b0eb70ab6b Mon Sep 17 00:00:00 2001 From: colenso Date: Wed, 16 Mar 2022 16:16:34 +0530 Subject: [PATCH 2/2] fix: don't change the existing function --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 109182c..9317f63 100644 --- a/index.js +++ b/index.js @@ -88,6 +88,13 @@ module.exports = { return tree; } - this._processTree(tree); + const workboxFunnel = new BroccoliWorkbox([tree], { + options: this._options, + workboxOptions: this.workboxOptions, + }); + + return mergeTrees([tree, workboxFunnel], { + overwrite: true, + }); }, };