This question is more theoretical then practical. Let's say I have project based on PHP framework Symphony/Zend, I also use gulp for frontend work. I would like to do this project in professional way, so I use gulp plugins like jade, clean, uglify, minify, gzip, imagemin and rev. If someone doesn't know what is this gulp-rev, here we go:
Static asset revisioning by appending content hash to filenames unicorn.css → unicorn-d41d8cd98f.css
Good thing for caching static files for example.
So, here is a problem...
I run gulp tasks and I got following files:
- assets
- css
- style-bfd65634.css
- js
- vendor-mkg5454.js
- img
- background-ok54353.png
etc...
After I finish my frontend work I want to put it in PHP framework's view files (phtml files), example: layout.phtml
...
<link type="text/css" rel="stylesheet" media="screen" href="<?php echo $this->basePath(); ?>/assets/css/style-bfd65634.css">
...
<div id="logo">
<img src="<?php echo $this->basePath(); ?>/assets/img/background-ok54353.png" />
</div>
...
and same thing goes with js files, images etc.
After few weeks I have to change something in CSS styles and what now?
How can I re-run gulp tasks without need to change phtml files from PHP framework? Or do I have to change modified files manualy in EVERY phtml file?
If so, then what is a point to use such plugins like gulp-rev? Just for static websites? As far as I know there is not any plugin which would convert jade files to phtml with PHP tags
You need to use gulp-inject to inject those newly created files in the specific location.
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- inject:css -->
<link rel="stylesheet" href="/src/style1.css">
<link rel="stylesheet" href="/src/style2.css">
<!-- endinject -->
</head>
<body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With