关于参数 asset 不起作用的疑问
think2011 opened this issue · comments
曾浩 commented
Hi,我遇到一个 asset
参数不起作用的问题。
我的动态文件路径是这个:
/WEB-INF/views/index.jsp
资源目录是这个
/src/index.js
我是这样引用的
<script src="src/index.js"></script>
所以使用 gulp-static-hash
时,我指定了 asset
参数为:'某某路径/'
很奇怪的是居然没有效果,于是我查看源代码。
里面对这个参数作了判断,只有开头为 /
的路径才能生效 asset
参数。
// 源代码
if (/^\//.test(filePath)) {
fullPath = path.resolve(asset, filePath.slice(1));
} else {
fullPath = path.resolve(mainPath, filePath);
}
很奇怪为什么要这样做,因为会导致参数无效。
曾浩 commented
因为某些原因,我不能这样写
<script src="/src/index.js"></script>
虽然这样能解决问题。
liang feng commented
当时的考虑是:src/index.js
作为相对路径,是相对于所处文件的。/src/index.js
是相对于资源根路径的。
曾浩 commented
那.. 这算是个bug吗?
--
think2011
Sent with Airmail
在 2015年8月3日 上午11:49:10, liang feng (notifications@github.com) 写到:
当时的考虑是:src/index.js作为相对路径,是相对于所处文件的。/src/index.js是相对于资源根路径的。
—
Reply to this email directly or view it on GitHub.
liang feng commented
很遗憾算不上,并且没办法修复
曾浩 commented
恩恩,知道了。