As designed Build add-on

kick

Well-known member
Affected version
2.1.3
My add-on uses several js files. And okay, I use minification. Next...
JSON:
"minify": [
    "js/MyAddon"
  ]
JSON:
"minify": [
    "js/MyAddon/*.js"
  ]
JSON:
"minify": [
    "js/MyAddon/*"
  ]
I can’t do wrong *, not * .js or as in additional_files I can’t just specify the path. But the minifier will generate an error for multiple files.
In JsMinifier.php line 41: [E_WARNING] file_get_contents
 
Syntax order?

And I don't see anything that says you can specify a wild card for files in the development docs. I would list each file individually.

Should be...
Code:
"additional_files": [
    "js/MyAddon"
],
"minify: [
    "js/MyAddon/filename1.js",
    "js/MyAddon/filename2.js",
    "js/MyAddon/filename3.js",
]

And if you don't want to include the non-minified versions...
Code:
"additional_files": [
    "js/MyAddon"
],
"minify: [
    "js/MyAddon/filename1.js",
    "js/MyAddon/filename2.js",
    "js/MyAddon/filename3.js",
],
"exec": [
    "rm _build/upload/js/MyAddon/filename1.js",
    "rm _build/upload/js/MyAddon/filename2.js",
    "rm _build/upload/js/MyAddon/filename3.js"
]

Pretty sure on the exec section. I don't think you'd need to do a separate "exec" for each file.

 
Last edited:
However according to the docs, @DragonByte Tech is correct.

The proper syntax for all files would be..
Code:
"additional_files": [
    "js/MyAddon"
],
"minify": "*"

Otherwise according to the docs, you have to specify each file in an array.
If you ship some JS files with your add-on, you may want to minify those files for performance reasons. You can specify which files you want to minify right inside your build.json. You can list these as an array or you can just specify it as '*' which will just minify everything in your js directory as long as that path has JS files within it after copying the additional files to the build. Any files minified will automatically have a suffix of .min.js instead of .js and the original files will still be in the package.
The key here is the code that's executed during the build process is sequential code. Each step is executed before going on to the next step.

So...
1) The additional files are copied to the _build folder
2) The js files in the _build folder are minified
3) (OPTIONAL in my first reply) The original non-minified files are removed from the _build folder.
 
Last edited:
@Snog, Thank you, and without you it was as if I did not know. Maybe start reading messages? I have several directories connected, even those that are written to the root of the forum. And I need to set a minifiers for .js files for one folder. Since there are 2 different folders with js additional_files allows you to specify the folders that will be copied without problems. The way to minimize everything is a crutch and a bad tone. I need only one folder and this is a bug. I do not speak already about the fact that the minimizer was prokinut through the third-party service where the files are sent and such a move is not at all clear. There is the same Node.js, there are a bunch of libraries in php. But such a move is also not clear. Or will you tell me now to build and then clean from what it minified. And do not poke me in the documentation, it is better to read it myself
 
I understood that you have multiple folders. But if you have multiple folders in the js folder and you only want one to be minified, then the documentation is quite clear that you need to list the actual files as an array and not use the "*" option. Nowhere in the documentation does it state that you can specify a folder with a wildcard.

So, it's debatable as to whether this is a bug or as designed. That's up to the XF developers to make that call. But IMHO, what you're reporting as a bug isn't a bug and is more of a suggestion because the process is not working as you want it to.
 
Last edited:
Top Bottom