69412

Yeoman vs UrlRouting

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.

<strong>Is there a way to deal with this issue?</strong>

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.

Answer1:

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.

Recommend

  • R function arguments and environments/namespaces
  • How to put HTML picture / text on the same line in a div?
  • yii2 create translated URLs
  • Index.php as custom error page
  • jParallax trouble
  • Symfony2 redirect to https route fails (uses wrong port)
  • PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea
  • Making header act like google chrome mobile app address bar
  • read values from form post in jquery or javascript
  • Does Apportable support to build library binary (.a/.so)?
  • Web.config system.webserver errors
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Use of this Javascript
  • Switching to Release Build causes runtime error in Web Reference
  • C++ Partial template specialization - design simplification
  • Different response to non-authenticated users and AJAX calls
  • How to set/get protobuf's extension field in Go?
  • Sending data from AppleScript to FileMaker records
  • Running a C# exe file
  • Symfony2: How to get request parameter
  • How to get next/previous record number?
  • Google cloud sdk not working when python points python3
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Why winpcap requires both .lib and .dll to run?
  • QuartzCore.framework for Mono Develop
  • 0x202A in filename: Why?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Python: how to group similar lists together in a list of lists?
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How to set the response of a form post action to a iframe source?
  • coudnt use logback because of log4j
  • Change div Background jquery
  • File not found error Google Drive API
  • Qt: Run a script BEFORE make
  • reshape alternating columns in less time and using less memory
  • Conditional In-Line CSS for IE and Others?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?