Maybe I did not understand something (most likely it is), but I still could not complete the following task:
There is a directory / src / js In it (without any nested directories) are .js files corresponding to different pages. The name of each of them starts with the name of the page (ie, for a single script of the services.php page, there will be a services.js script) Almost all of these scripts use jQuery. Therefore, to restore order in the final version, it was necessary to add one file ( jquery.min.js ) to the beginning of each file from the input stream ( ./src/js/ .js *). It was not possible to do this. So how can this (add an arbitrary file or several to the beginning of each output) be implemented without having to manually describe the addresses of each source file and a whole mountain of unknown tricks related to this?
PS: a somewhat similar question in CSS: There is an office, specially prepared (unnecessary trash is removed, etc.) bootstrap.min.css The project is done using LESS (foo, well, okay). That is, first all the necessary .less files are compiled, then minified, giving candy to the output.
The problem is that css file in LESS is not so simple: a. if you connect it as css ( @import (css) "address"; ), then in the final CSS file there will be just a link to it (that is, the CSS import of the corresponding file will be assigned ) b. if you connect it as less ( @import (less) "blablabla"; ), then errors begin to pour, because it is not only not LESS, so also minimized. There was an idea to screen all this, enclosing the entire contents of the renamed bootstrap.min.less into ~ "css-code, which is not checked by the preprocessor at all, but is immediately splashed into the output file" , however, this was not possible, due to the abundance in the mentioned as single and double quotes.
Therefore, a similar question: how to each of the received css files (one css file is obtained per page with the exception of bootstrap), put the contents of some file ( bootstrap.min.css ) at the beginning?
<script ... >
just above your scripts on those pages where you really need it. What you are trying to do is a monstrous crutch. - Dmitriy Simushev February