Simple web framework - improvements to makefile

Joined
Feb 1, 2023
Messages
1
Reaction score
0
I am building a website using no framework with a folder structure like this:
src
|---components
|--Navbar
|--index.html
|--index.css
|--index.js
|---pages
|---page1
|--index.html
|--index.css
|--index.js
|--page2
|--index.html

out
->page1.html
->page2.html


First I would like to automatically add script/head tags for the pages/<page>/{js,css} into the pages/<page>/html. Secondly I would like to auto expand any <Component_Name/> tags in my pages html files with the appropriate html from the components folder (logically you have to include the components own css and js).
Coming from React/Next.js I realize that this is the most nonsensical anarchy approach to web-dev "frameworks", but it's suppose to be more of a learning project than anything else.
First things first, what would be the best tool for this? I decided to use Makefiles but since the makefile looks pretty awfull I am not so sure it was the right choice.

Here is my code to accomplish the aforementioned: https://github.com/ElectricPulse/FirstSumecPCWebsite/tree/main
The page/component logic is in the file Pages.mk.

I am not so sure how to implement the actual markers as prerequisites, so many of the rules dont produce the target they are suppose to, is this bad?

I tried to implement this with more Bash, thats in the archived branch in the Makefile, but that was just way too ugly.

Also I know that the code technically loops over all the pages three times when matching the components (one iteration for css, one for js, one for html) and not one time like it should be, how could I get rid off that?

Another thing I wasnt able to figure out, is how you are suppose to send errors from the bash part of the rule into make, currently I just have a useless echo that doesnt stop the actual makefile build process.

Any other tips and tricks you might think of?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,836
Messages
2,569,747
Members
45,545
Latest member
rapter____0

Latest Threads

Top