Skip to content

Commit

Permalink
chore: removed asset prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jpina1-godaddy committed Jan 17, 2024
1 parent 147b488 commit 889a9ac
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 41 deletions.
2 changes: 0 additions & 2 deletions packages/gasket-plugin-workbox/lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ const {
* @returns {Promise<Object>} config
*/
module.exports = async function configure(gasket, config) {
const { logger } = gasket;
const workbox = getWorkboxConfig({ config });
const basePath = getBasePath({ config });

if ('assetPrefix' in workbox) logger.warning('DEPRECATED workbox config `assetPrefix` - use `basePath`');
workbox.basePath = basePath;

const { version } = require('workbox-build/package');
Expand Down
4 changes: 2 additions & 2 deletions packages/gasket-plugin-workbox/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ function getOutputDir(gasket) {
*/
function getBasePath(gasket) {
const { workbox = {}, basePath: rootBasePath } = gasket.config;
const { basePath, assetPrefix } = workbox;
const { basePath } = workbox;

return [basePath, assetPrefix, rootBasePath, ''].find(isDefined);
return [basePath, rootBasePath, ''].find(isDefined);
}

module.exports = {
Expand Down
9 changes: 0 additions & 9 deletions packages/gasket-plugin-workbox/test/configure.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ describe('configure', () => {
]));
});

it('configures basePath with deprecated assetPrefix', async function () {
mockGasket.config.workbox = {
assetPrefix: '/some/prefix'
};
results = await configure(mockGasket, mockGasket.config);
expect(results.workbox).toHaveProperty('basePath', '/some/prefix');
expect(mockGasket.logger.warning).toHaveBeenCalledWith('DEPRECATED workbox config `assetPrefix` - use `basePath`');
});

it('add basePath to script path', async () => {
mockGasket.config.workbox = {
basePath: '/some/prefix'
Expand Down
30 changes: 2 additions & 28 deletions packages/gasket-plugin-workbox/test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@ describe('getWorkboxConfig', () => {
});

it('returns config from gasket.config.js', () => {
const results = utils.getWorkboxConfig(setupGasket({
workbox: {
assetPrefix: 'BOGUS'
}
}));
expect(results).toEqual({
...utils.defaultConfig,
assetPrefix: 'BOGUS'
});
const results = utils.getWorkboxConfig(setupGasket({}));
expect(results).toEqual({ ...utils.defaultConfig });
});
});

Expand All @@ -38,32 +31,13 @@ describe('getBasePath', () => {
expect(results).toEqual('//cdn-a');
});

it('returns the assetPrefix from workbox config', () => {
const results = utils.getBasePath(setupGasket({
workbox: {
assetPrefix: '//cdn-a'
}
}));
expect(results).toEqual('//cdn-a');
});

it('returns the basePath from next config', () => {
const results = utils.getBasePath(setupGasket({
basePath: '//cdn-b'
}));
expect(results).toEqual('//cdn-b');
});

it('returns the basePath from workbox config over next', () => {
const results = utils.getBasePath(setupGasket({
workbox: {
assetPrefix: '//cdn-a'
},
basePath: '//cdn-b'
}));
expect(results).toEqual('//cdn-a');
});

it('returns empty string if not configured', () => {
const results = utils.getBasePath(setupGasket({}));
expect(results).toEqual('');
Expand Down

0 comments on commit 889a9ac

Please sign in to comment.