Me and my team are on the break of rebuilding the frontend of a large CakePHP 2 application. The main goal, other than a new look, is to have more reusable SCSS/Javascript, to have a logical structure in our own frontend code and 3rd party assets we use.
Right now we have 1 CSS file where we 'patch' whatever CSS we need to the bottom of it, not looking at other classes that we can re-use, there is no structure to it.
Most of the Javascript goes 'inline' into the views, which does mean that all functionality of that view can be found inside the view file itself, but other than that, no structure either, nothing becomes re-usable and everything either has to be re-made or copied.
We do have functions that are used in more places, but all of those are also in 1 file (you know how it goes, the general.js or the common.js included on every page).
Question
So my question is, what is a good structure or architecture for things like Javascript and CSS/SCSS in a CakePHP application. Where can one begin?
My ideas
Currently we don't use things like a CSS preprocessor or a frontend package manager like bower. Preprocessing CSS (in our case SCSS) is definitely one we are going to implement and I'm going to look into using bower for our project, making it easier to manage the 3rd party assets we use.
On the Javascript side, I guess auto-loading a Javascript file with the same name as the CakePHP Controller and the action, if exists, can already bring some structure to it, but what about the code in those files? Does it perhaps extend a 'master' Javascript object so it has a lot of ready-to-go functions? And what about the common scripts that are used on every page? Do I go for seperate functions or perhaps 1 big object with a single instance which can then be used on all pages?
Found resources:
How to structure Javascript architecture to complement a PHP MVC web app? => There is no real answer that applies to me in this question
https://www.sitepoint.com/architecture-in-sass/ => Gave me some insights in how to structure SASS.
JS MV* Frameworks like https://angularjs.org/ => Because the application is fairly large already, we simply don't have the time and resources needed to rebuild the backend to support a JS MVC framework like AngularJS. Perhaps I need to read up more on these, but they seem over-complicated for my application.