Skip to content

Commit 4301882

Browse files
committed
fix publicPath
1 parent f626f72 commit 4301882

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ module.exports = class RequireSplitChunkWebpackPlugin {
8787

8888
/** 完成编译后的同步钩子 */
8989
afterCompilation(compilation: Webpack.compilation.Compilation) {
90-
// 优化每个资源时触发
90+
// 优化资源时触发
9191
compilation.hooks.optimizeChunkAssets.tap(this.name, (chunks) => {
9292
const assets: Assets = compilation.assets;
9393
const entryFiles = this.getScriptFile(chunks.filter((chunk) => chunk.hasEntryModule()));
@@ -112,9 +112,11 @@ module.exports = class RequireSplitChunkWebpackPlugin {
112112
if (!this.checkAllow(compiler)) {
113113
return;
114114
}
115-
115+
116+
const { output } = compiler.options;
117+
116118
// 读取编译配置
117-
this.publicPath = compiler.options.output?.publicPath || '';
119+
this.publicPath = output?.path || output?.publicPath || '';
118120
// 完成编译时触发
119121
compiler.hooks.compilation.tap(this.name, this.afterCompilation.bind(this));
120122
}

0 commit comments

Comments
 (0)