Note that there are some explanatory texts on larger screens.

plurals
  1. POIn a framework using rewrite rules, how best to integrate CSS and JS?
    primarykey
    data
    text
    <p>I've got a framework that routes all incoming URIs through a base file, and to deal with static files I've got a sub-directory /static in which I put all CSS, JS and images (ie. /static/css/main.css) in order to keep things clear.</p> <p>My own code and plugins deal with this fine, but some times other code needs to be implemented, and often CSS files will try to style up with calls to URIs in those files. How can I deal with this in the best way?</p> <p>An example ;</p> <p>/about/company routes to /script?q=about/company and locks in the main structure of the site. However; /static/css/main.css uses a background image from; /static/images/widget/bg-color.png</p> <p>Since this is a framework I'm not happy to hard-code the /static paths in the CSS files. For one, I don't want to restrict websites to only being served from some root directory. :) For all JS there's objects that deal with this (ie. var x = $xs_dir.js + '/script.js' ;) but nothing exists for CSS. I have five options, I think ;</p> <ol> <li><p>(worst) Have an option in my admin tool that scans all CSS files for URI references, and prepends them with the right static directory, and writing all CSS as if they're static to a root directory.</p></li> <li><p>(poor) Rely on the webserver's ability to alias any static directory to one root static directory, and let the admins deal with it.</p></li> <li><p>(meh, slow) Serve the CSS files through the framework, filtering URIs with the right static paths.</p></li> <li><p>(simplest, but not very easy) Hand-code the static portions of my CSS files for whatever server setup there might be, and just make sure they're easy to find and change.</p></li> <li><p>(probably best, but complex?) Have a rewrite rule that detects images in current directory, forwarding them to the static directory, and write all CSS with some recognized dynamic path. (ie. instead of /static/images/img.png do images/img.png and rely on rewrite rules to push it where it needs to go, also restricting the website structure to never have a sub-directory called 'images')</p></li> </ol> <p>Any additional options? Ideas? I know Joomla and similar has some rewriting of files, and probably do no. 5?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload