News for hackers. Stuff that matters.
Re:PHP in 2024 by kijin on Wednesday April 10, 2024 @03:59AM (#39988143)
I'm taking the "no build step" thing to the extreme in one of my projects.

PHP has libraries for compiling SCSS and minifying JS, and filemtime() is very fast. So if you wire them together in just the right way, you can edit any script or stylesheet under the project hierarchy and have them compiled, minified, and bundled together on the fly. Cache the bundle until you edit one of them files again, and automatically bust the cache once you do.

No need to build anything whatsoever, both on the frontend and on the backend. It's like REPL over HTTP.

Re:PHP in 2024 by todotask on Wednesday April 10, 2024 @04:52AM (#39988459)
> PHP has libraries for compiling SCSS and minifying JS, and filemtime() is very fast

If you do compiling and minifying, that's a build step.

Re:PHP in 2024 by wildrhythms on Wednesday April 10, 2024 @05:54AM (#39988860)
The usage of the term 'step' here is in the pre-deployment development process sense. I think what this person is doing is converting SCSS to CSS on request, at runtime.
Re:PHP in 2024 by todotask on Wednesday April 10, 2024 @06:39AM (#39989162)
Regardless of which steo, compilation process is typically done as part of a build step, where the SCSS files are transformed into the final CSS that will be served as a bundle to the end users' application.

Web browsers can't understand SCSS natively.

To be truly extreme (performance), devs should consider tree-shaking unused CSS and JavaScript. This may require using Vite (Rolldown is in the works/Rollup) if there are no other options or it makes no sense to serve bloated resources. That's the reason, I chose Astro as I care about users, not prioritse the developers' minimalistic workflows.

I prefer Tailwind because it allows me to avoid duplicating classes (mine and vendors), which is an advantage over other approaches.

I did dogfooding in Go development.

Re:PHP in 2024 by kijin on Wednesday April 10, 2024 @07:36AM (#39989523)
Every human-readable programming language needs to be compiled into some sort of bytecode (opcode in PHP) and/or machine language in order to work. The question is whether a human ever needs to be aware of that step. In PHP, you generally don't. In the aforementioned setup, you don't need to be aware of SCSS compilation and minification, either. Not even if you use devtools, because the map file will point to the correct line in the original source.
Re:PHP in 2024 by hu3 on Thursday April 11, 2024 @08:46PM (#40008330)
I can confirm, this approach works great!

I use this in production for a system with 3k requests per second that runs in a single Apache+PHP web server and a single 80GB MySQL database. Never needed to optimize anything.

You have no idea how happy it makes me to see someone else was bold enough to try this and it worked for them too.

Simple, maintainable, instant SCSS and JS build pipelines with all the benefits and no drawbacks! Plus any junior can understand and change it in minutes.