Skip to content

Commit

Permalink
fix: rebase pr onto upstream/master
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Dec 2, 2020
1 parent f697eff commit 6e28e3a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ const emitHook = function emit(
compilation
) {
const emitCount = emitCountMap.get(manifestFileName) - 1;
const publicPath =
options.publicPath !== null ? options.publicPath : compilation.options.output.publicPath;
// Disable everything we don't use, add asset info, show cached assets
const stats = compilation.getStats().toJson({ all: false, assets: true, cachedAssets: true });
const stats = compilation
.getStats()
.toJson({ all: false, assets: true, cachedAssets: true, publicPath: true });
const publicPath = options.publicPath !== null ? options.publicPath : stats.publicPath;
const { basePath, removeKeyHash } = options;

emitCountMap.set(manifestFileName, emitCount);
Expand Down
21 changes: 20 additions & 1 deletion test/unit/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,26 @@ test('prefixes paths with a public path', async (t) => {
});
});

test('is possible to overrides publicPath', async (t) => {
test('prefixes paths with a public path and handle [hash] from public path', async (t) => {
const config = {
context: __dirname,
entry: {
one: '../fixtures/file.js'
},
output: {
filename: '[name].js',
path: join(outputPath, 'public-hash'),
publicPath: '/[hash]/app/'
}
};
const { manifest, stats } = await compile(config, t);

t.deepEqual(manifest, {
'one.js': `/${stats.hash}/app/one.js`
});
});

test('is possible to override publicPath', async (t) => {
const config = {
context: __dirname,
entry: {
Expand Down

0 comments on commit 6e28e3a

Please sign in to comment.