I’ve used Gulp for maybe 2 years now but there are a few reasons why I don’t love it anymore:
- When I backup or move the project to a new location I need to copy Gulp as well and it has a lot of files which is a nag. I could probably ignore the Gulp files but then I need to set up Gulp again on the new location.
- Everytime I save an asset, it saves the file to disc. Sometimes it fails. It can be an error in my Sass/js or some other reason.
- Everytime I start a new project I need to set up Gulp on the new projects (I don’t want to set it up globally) and it takes some time everytime.
It feels like a big dependency that I should not need.
The only reason I use Gulp is this:
- Convert nested scss files to css
- Concat (merge files together) js and css
- Autoprefix css
- Minify js and css
I’m thinking about moving to a simple plain PHP setup instead. Then I would need a function to convert nested css, concat, autoprefix and minify these assets. I don’t need Sass for it, but it’s a possibility.
The pitfall people mention is that it’s bad to compile this on every pageload and I agree. My idea is to compile it everytime on the development enviroment when a config is set c::set('compile.assets', true);
.
Maybe it could even turn into a plugin. It could for example simplify the use of Kirby Patterns and Kirby Bricks.
I would like any kind of feedback on this.
doing these jobs in php right seems daunting.
why not use preprocessor apps instead?
setting up new projects is easier if you like gui.
or on mac
I’ve tried both Prepros and Koala but I think that the problems remains. Why do you think it’s daunting?
On every page refresh the asset could be built and saved, but it does not have to be. It could instead check if the file(s) has been updated (compare dates) and only build the asset if it has changed. Then it does not need to read the files if not needed.
finding well maintained php libs for preprocessing assets. assembling the plugin and keep it updated for a few years since the used libs will change.
also usecases vary greatly like the diversity of proprocessor apps prove. your described usage of gulp is the most minimalistic yet useful web preprocessor i can think of. i use preprocessors or gulp/grunt to do many things more (lint, babel, bower, updating, coffeescript, image optimisation, uploading, zipping, moving files … ) and would have no need for a kirby scss/js preprocessor plugin.
but I can understand why you do not want to use them.
When you still depend on npm you can do simple tasks directly with node scripts.
Sadly there will always be some overhead. When you use npm as a package manager I personally think the overhead is negligible because you will always run npm i
no matter what. And then it would make no difference if you need to copy a gulpfile or a plugin to get your assets bundled.
I can also fully agree with what @bnomei wrote.