Skip to content

Commit f6d43f8

Browse files
committed
fix: bug of output.publicPath
Didn’t remove external link from html
1 parent 4b34386 commit f6d43f8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Compiler } from 'webpack';
1+
import { Compiler, Configuration } from 'webpack';
22

33
type File = {
44
[key: string]: string
@@ -43,13 +43,14 @@ export default class Plugin
4343
});
4444
}
4545

46-
private process({ assets }: Compilation) {
46+
private process({ assets }: Compilation, { output }: Configuration) {
47+
const publicPath = (output && output.publicPath) || '';
4748
Object.keys(this.html).forEach((htmlFileName) => {
4849
let html = this.html[htmlFileName];
4950

5051
Object.keys(this.css).forEach((key) => {
5152
html = Plugin.addStyle(html, this.css[key]);
52-
html = Plugin.removeLinkTag(html, key);
53+
html = Plugin.removeLinkTag(html, publicPath + key);
5354
});
5455

5556
assets[htmlFileName] = {
@@ -62,7 +63,7 @@ export default class Plugin
6263
apply(compiler: Compiler) {
6364
compiler.hooks.emit.tapAsync('html-inline-css-webpack-plugin', (compilation: Compilation, callback: () => void) => {
6465
this.prepare(compilation);
65-
this.process(compilation);
66+
this.process(compilation, compiler.options);
6667
callback();
6768
});
6869
}

0 commit comments

Comments
 (0)