If you don’t want any deformation whatever the size of each face, it’s getting a lot more complicated.
See for eg:
- How to scale and orient PBR material textures? - #5 by Evgeni_Popov
- Apply different UV scale per object for same material, is that possible? - #18 by Evgeni_Popov
But it’s always very specific to a cube or a rectangle…