HTML5 Boilerplate Build 脚本 - 子文件夹中的 HTML 以及 CSS/JS 问题的相关链接
我的项目使用 HTML5Boilerplate 并包含带有 HTML 文件的子目录,这些文件引用主根文件夹中的 /js 和 css/ 。
例子: /article/xxx/index.html /article/yyy/index.html
这些 .html 文件具有到根文件夹中 css/js 文件的相对路径 href/src。
<link rel="stylesheet" href="../../css/style.css" />
<script src="../../js/plugins.js"></script>
<script src="../../js/script.js"></script>
我试图让构建脚本识别子目录中的这些文件,并相应地替换连接/缩小的 JS 和 CSS 文件的路径,我尝试将其添加到 project.properties 上的 file.pages 属性中,
file.pages = index.html, article/xxx/*.html, article/xxx/*.html
但没有骰子,CSS /JS 路径被替换,就像文件位于根文件夹中一样,如下所示:
<link rel=stylesheet href='css/7d3586f292b65c896ef495e2e8ef042901d7c2e2.css'>
这显然不起作用。 如果有人知道解决方法/修改,或者这可能只是一个不行的话,我将非常感激?
预先感谢任何帮助:D
My project is using HTML5Boilerplate and contains subdirectories with HTML files that reference /js and css/ in the main root folders.
Example:
/article/xxx/index.html
/article/yyy/index.html
These .html files have relative path href/src to the css/js files in the root folder.
<link rel="stylesheet" href="../../css/style.css" />
<script src="../../js/plugins.js"></script>
<script src="../../js/script.js"></script>
I'm trying to have the build script recognise these files in the subdirectories and replace the paths accordingly to the concatenated/minified JS and CSS files and I tried adding this to the file.pages property on project.properties
file.pages = index.html, article/xxx/*.html, article/xxx/*.html
But no dice, the CSS/JS paths get replaced as if the files are in the root folder, like so:
<link rel=stylesheet href='css/7d3586f292b65c896ef495e2e8ef042901d7c2e2.css'>
Which doesn't work evidently.
Would be really grateful if anyone knows a workaround/modification for this or if this might just plain be a no-go?
Thanks in advance to any help :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以尝试使用
glob 模式可能会更好地符合构建脚本。我刚刚在一个空项目上测试了这个,index.html 文件位于
article/fold1/
和article/fold2/
下,两者的相对路径与我得到的
相同,它可能会让您在更新文章文件夹下的 html 文件时省去一些麻烦,
**/*.html
模式将捕获这些目录中的所有 html 文件。Maybe you could try to use
the glob pattern may comply better with the build script. I just tested this on an empty project, with index.html files under
article/fold1/
andarticle/fold2/
, both with the same relative path than yoursI get
also, it might save you some headache to update html files under your articles folder, the
**/*.html
pattern will catch up any html files within these directories.您需要编辑 build.xml 脚本。在第 630 行左右,使用正则表达式替换对串联版本的 js 和 css 引用,但它不考虑子目录。我将其中的行更改为:
我想正则表达式可以更有效。
西蒙
You need to edit the build.xml script. Around line 630 a regex is used to replace the js and css references to the concatenated versions but it does not take account of subdirectories. I changed the lines there to:
I imagine the regex can be more efficient.
Simon