Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top