Skip to content

Commit

Permalink
fix: add support for webpack@5 'auto' publicPath
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Oct 30, 2020
1 parent fb1b5ed commit 30c0d35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ module.exports.run = (faviconOptions, context, compilation) => {
function getPublicPath(faviconsPublicPath, compilerPublicPath) {
return faviconsPublicPath !== undefined
? faviconsPublicPath
: compilerPublicPath !== undefined
: compilerPublicPath !== undefined && compilerPublicPath !== 'auto'
? compilerPublicPath
: '/';
}
Expand Down
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ class FaviconsWebpackPlugin {
...options
};
}

apply(compiler) {
compiler.hooks.initialize.tap('FaviconsWebpackPlugin', () => {
this.hookIntoCompiler(compiler);
});
}

hookIntoCompiler(compiler) {
const oracle = new Oracle(compiler.context);

{
Expand Down
10 changes: 3 additions & 7 deletions test/oracle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test('should infer missing information from the nearest parent package.json', as

{
const plugin = new FaviconsWebpackPlugin(logo);
plugin.apply(compiler({ context }));
plugin.hookIntoCompiler(compiler({ context }));

t.is(plugin.options.favicons.appName, pkg.name);
t.is(plugin.options.favicons.version, pkg.version);
Expand All @@ -42,7 +42,7 @@ test('should infer missing information from the nearest parent package.json', as

{
const plugin = new FaviconsWebpackPlugin(logo);
plugin.apply(compiler({ context }));
plugin.hookIntoCompiler(compiler({ context }));

t.is(plugin.options.favicons.appName, undefined);
t.is(plugin.options.favicons.version, undefined);
Expand All @@ -60,11 +60,7 @@ test('should parse author string from package.json', async t => {
});

const plugin = new FaviconsWebpackPlugin(logo);
plugin.apply(
compiler({
context: t.context.root
})
);
plugin.hookIntoCompiler(compiler({ context: t.context.root }));

t.is(plugin.options.favicons.developerName, parseAuthor(pkg.author).name);
t.is(plugin.options.favicons.developerURL, parseAuthor(pkg.author).url);
Expand Down

0 comments on commit 30c0d35

Please sign in to comment.