Yeoman vs UrlRouting

你离开我真会死。 提交于 2019-12-25 02:32:46

问题


I see how Yeoman work perfectly for a single-page webapp, but I struggle when I try to make it work for a simple php webpage.

I have a simple problem: yeoman deals with caching, by renaming the assets, which is cool.

Now let's assume, that your webpage is using UrlRouting, so an url like "/news/12/Puppies" would get redirected to the index.php file.

Let's also assume, that you have a function, that will set a correct absolute url to the assets, based on the project root: absoluteUrl().

Your header then could have the following lines:

<!-- build:css(.tmp) styles/style.css -->
    <link rel="stylesheet" href="<?= absoluteUrl('styles/style1.css') ?>">
    <link rel="stylesheet" href="<?= absoluteUrl('styles/style2.css') ?>">
<!-- endbuild -->

Which of course does not work with yeoman.

Is there a way to deal with this issue?

One solution I thought up is to copy all the relevant html files, strip the absoluteUrl part , run the grunt tasks on these, then add the absoluteUrl call back again. But I rather not use such an unelegant technique.


回答1:


Since I posted this question, I had a lot of time wrestling with this question. What I did for a solution is to remove the absoluteUrl function call from the index with a grunt task, running the asset handling yeoman tasks, then place it back after everything is OK.

It worked fine, but I think it's risky. Too much magic involved, a lot of things can go wrong.



来源:https://stackoverflow.com/questions/22779809/yeoman-vs-urlrouting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!