Using Sage without nodejs/npm

Just getting into roots/sage and love the approach and coding style but I work on very lean ubuntu machines and not happy about installing npm which pulls in 100Mb of dependencies plus python (of all things) and I’d rather avoid that in general. I haven’t looked at Bedrock yet so perhaps it would be possible to use only composer for the build system?

Can anyone suggest a way to continue using the roots/sage system with only PHP and Bash as a dependencies?

You can use a deployment process in which you build your assets on a local machine or some type of continuous integration system.

I went ahead and played along with the video tutorial and website instructions and I think it simply comes down to emulating the steps that go into creating the contents of the dist/ folder so I should be able to add an external command to wp-cli without too much fuss. The browsersync stuff is a nice touch but I can easily live without that if it doesn’t involve the rather large nodejs/npm/python set of dependencies. Besides it seems hardwired to localhost:3000 and that is not available to me from outside of a lxc container anyway. I already have PHP installed (duh) and I rely on wp-cli to preconfigure WP installs so adding an extra command module to wp-cli to also “compile” the sage dist/ folder seems like the simplest way forward. I just love the roots/sage approach to dealing with WP themes, and the coding style, but the surrounding sage support framework is kind of bizarre (to me).

Without node/npm there would be no way to compile assets using the gulpfile, which I would argue is one of the main benefits to using Sage.

So as long as you don’t want to use any of that asset compiling stuff, go ahead. I could see a benefit to just using the wrapper and other stuff I guess, but I’d hate to be without the awesomeness that is that gulpfile.

Yeah maybe I haven’t grokked the awesome enough yet to appreciate the benefits. There are less and sass compilers, and CSS/JS minifiers, written in pure PHP so I’m not sure what part of the compiling process could not be done in PHP-land. Am I missing some important step in the asset compile procedure (re-compressing images is no problem)?

You could totally write PHP tasks to minify/concatnate/squish/squash your LESS/SASS/whatthefuckever but I would never want to do that. I’d rather use a quick tool that’s built for running tasks like that, like grunt or gulp. To me, that’s worth the npm install process all day…

Appreciate your viewpoint but for me the impedance mismatch of having to deal with an otherwise entirely foreign framework that I have no other use for leads me to spend time trying to replace the essential parts to be able to keep using the Sage system. As mentioned, my first gotcha is not being able to access localhost:3000 from outside a container (or any remote host) and I have no idea where to change that setting within the mass (mess?) of node modules. This won’t be the last issue so I’d rather spend my time hacking around in PHP-land. If I can pull this wp-cli command idea off then I only have to deal with a single 1.5Mb phar file to manage “everything” to do with WP and Sage.

Nobody is forcing you to use Sage, or all parts of Sage. It’s fairly delete key friendly. If you don’t like a specific part of what it does or the fact that it uses industry-standard tools that depend on node/npm to get some tasks done, delete those and make the build that works for you.

Happy Easter!

Strongly recommend you reconsider avoiding using node and npm. I understand your reservations but ignoring the node ecosystem will put you back in the stone age as far as the tools available to make your job easier. After reading your comments I feel as though you are being penny-wise and pound-foolish.

When I don’t use gulp I usually use a standard Makefile.

Here are some examples of Makefiles I have seen. I do something that approximately works like these from time to time.

Thanks for your interesting makefile suggestion. There could be a place for make but I’d try inotifywait in a shell script first and see how that goes. There is also a inotify pecl extension which I’ve never tried. I’m primarily interested in taking advantage of the sage theme wrapper class so even if I built a plain CSS snapshot of all the less files and git managed them manually then I may be able to live with that but there is the PHP iLess project which can build bootstrap3 and strip whitespace so working from the less files should also be possible.

Hopefully I will have a fledgling github repo to test some ideas in a few days so I may have something tangible to contribute.

Like I have already said, I just so love the roots/sage PHP code style that I just wish all of WP was written the same way but to be absolutely frank, the more I use node/npm the less I want to use it (and I was a very keen nodejs user many years ago before npm became available.)

Grunt and gulp are just task runners. There are similar things in PHP:

https://www.google.com/search?q=php+task+runner&oq=php+task+runner&aqs=chrome..69i57j69i64.1771j0j7&sourceid=chrome&es_sm=119&ie=UTF-8
http://robo.li/
http://bldr.io/
https://taskphp.github.io/