Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用自定义filename输出html文件时,html内引入的资源路径出错 #26

Open
HexMox opened this issue Jun 28, 2018 · 0 comments

Comments

@HexMox
Copy link

HexMox commented Jun 28, 2018

webpack配置
publichPath: '//7.url.cn/edu/user/'

插件配置

filename: (n) => `${n}/${n}`

Resource.js

                // add a file to newNodes
		const outToNewNodes = (fileName, fileContent) => {
			// resource should load in URL relative to html output path
			let resourceRelative2HTMLPath = url.resolve(webpackOutputPublicPath, fileName);
			resourceRelative2HTMLPath = util.urlRelative(htmlOutputURL, resourceRelative2HTMLPath);
			resourceRelative2HTMLPath = url.resolve(webpackOutputPublicPath, resourceRelative2HTMLPath);

			if (type === 'script') {
				// output js file only
				...
			} else if (type === 'style') {
				// output css file only
				...
			} else if (type === 'other') {
				...
			}
		};

此类情况当执行到上面Resource.js文件的outToNewNodes方法时,resourceRelative2HTMLPath最终计算出资源文件的路径为//7.url.cn/edu/[name],故html加载资源的路径出错。

注释掉这两行代码后,跑通

// resourceRelative2HTMLPath = util.urlRelative(htmlOutputURL, resourceRelative2HTMLPath);
// resourceRelative2HTMLPath = url.resolve(webpackOutputPublicPath, resourceRelative2HTMLPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant