Skip to content

Commit

Permalink
Use public path with entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
webdeveric committed Jan 12, 2021
1 parent cca0785 commit 566d678
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/WebpackAssetsManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,13 @@ class WebpackAssetsManifest
if ( this.options.entrypoints ) {
const removeHMR = file => ! this.isHMR(file);
const getExtensionGroup = file => this.getExtension(file).substring(1).toLowerCase();
const getAssetOrFilename = this.options.entrypointsUseAssets ?
file => this.assets[ findAssetKeys( file ).pop() ] || this.assets[ file ] || file :
undefined;
const getAssetOrFilename = file => {
const asset = this.options.entrypointsUseAssets ?
this.assets[ findAssetKeys( file ).pop() ] || this.assets[ file ] :
undefined;

return asset ? asset : this.getPublicPath( file );
};

const entrypoints = Object.create(null);

Expand Down
25 changes: 23 additions & 2 deletions test/WebpackAssetsManifest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,27 @@ describe('WebpackAssetsManifest', function() {
},
});
});

it('entrypoints are prefixed with publicPath when entrypointsUseAssets is false', async () => {
const { manifest, run } = create(
configs.hello(),
{
entrypoints: true,
entrypointsUseAssets: false,
publicPath: 'https://example.com/',
},
);

await run();

expect( manifest.get('entrypoints') ).to.deep.equal({
main: {
assets: {
js: [ 'https://example.com/main.js' ],
},
},
});
});
});

describe('entrypointsKey', function() {
Expand Down Expand Up @@ -1232,8 +1253,8 @@ describe('WebpackAssetsManifest', function() {
const { entrypoints } = manifest.toJSON();

expect( entrypoints.main.assets ).to.deep.equal({
css: [ 'main-HASH.css' ],
js: [ 'main-HASH.js' ],
css: [ 'https://assets.example.com/main-HASH.css' ],
js: [ 'https://assets.example.com/main-HASH.js' ],
});
});
});
Expand Down

0 comments on commit 566d678

Please sign in to comment.