cli
cli copied to clipboard
[feature requests] Multiple bundles/targets & platforms
I've been trying to figure out how to support multi-spa and leverage build targets and platform in aurelia.json to support a more sophisticated build setup.
attempts:
- just standard splitting bundles to break off dependencies (each SPA may have different 3rd-party vendor libraries): https://github.com/diegohb/samples-aurelia-vanilla_cli/tree/master-task017 --this broke the karma tests but otherwise worked.
- tried to trick the au bundler to update a razor partial that each razor view references so that both root container SPA pages get the bundler rewrite: https://github.com/diegohb/samples-aurelia-vanilla_cli/tree/master-task018
- Now i'm trying to specify SPA-specific bundles and hopefully share the common aurelia & systemjs bundle in both..
The requests:
-
ability to specify array of strings to build.targets[x].index . eg ["index1.html", "index2.html"]
-
change updateIndexForConfig() method to work against any type of file, just look for
-
change build.loader.configTarget property to reference build.targets.id to load it's .index property. This will help avoid having an additional place to change the value of index page to be updated.
-
add property "buildTarget" to bundle object that works like dependencies[x].env property (can specify multiple target concatenated with ampersand).
-
add property "platform" to buildTarget to specify what targets are meant for which platforms and then allow parameter "platform". eg. au build --platform "netcore2.0" or "electron" etc..
I wonder if anyone can provide links to source file(s) related to each one of these requests ? I'd love to look at helping out with some.. maybe the first one for starters.. 😃
i see it's related to https://github.com/aurelia/cli/issues/442
I'd love to know why this isn't working as expected to get a better understanding of the internals of the cli and current limitations .. https://github.com/diegohb/samples-aurelia-vanilla_cli/commit/20e557b5acb73e04a7f63d915494da27125cf41b 🆘
@diegohb i'd like to help you debug but i''m a bit behind on all my other work. If you can wait until next weekend I can help you out
@JeroenVinke - thanks a lot! 👍 👍 👍
Adding the following code to the top of my build.js
file I can specify au build --target mobile
import project from '../aurelia.json';
let target = "web";
if (CLIOptions.hasFlag("target")) {
target = CLIOptions.getFlagValue("target")
}
let targetIndex = project.build.targets.findIndex(x => x.id === target);
if (targetIndex < 0) targetIndex = 0;
project.build.targets[0] = project.build.targets[targetIndex];
This is only as a work-around for now until we can get a better solution.
@johan-v-r - thanks! that's a great add.. i tried to pull down code also and was going to implement request 1 (multiple index files to update) but I couldn't get my environment setup right.. running karma on cli project causes spec test failures.. hesitant to code without having a good test baseline to start from.
I found the code that updates the index page and it does not actually care about what kind of file it's pointed to.. so my request number 2 above is unnecessary.
https://github.com/aurelia/cli/blob/aab947791010d714e7a98ad1438ca152ba0ceddf/lib/build/bundle.js#L334
I can't really find any documentation or code related to platform.index property at the top of the aurelia.json file - doesn't seem to be used?
That's used to replace the reference to the vendor bundle when revisions are used, so a user doesn't have to manually update the links with the generated vendor bundle hash. Should be documented somewhere in the CLI docs...
@AStoker - I don't think Platform.Index (at the top of the aurelia.json) is used for that.. you mean targets[x].Index - that is used for that.
either way, I've managed to get the revision update to work against an MVC partial so that way I can have multiple SPAs refer to the same bundle revision and sitll leverage CLI auto-update for that - https://github.com/diegohb/samples-aurelia-vanilla_cli/compare/master-task018
You're correct, my mistake :)
@diegohb I've added a PR, https://github.com/aurelia/cli/pull/765, that will implement build targets. I think it will cover some of your needs, but not all of them. Could you take a look and let me know what's missing that you need?
@jwx thanks a lot! Item 2 can be ignored because it already works that way, index file can be any type of file as long as regex matches. Item 3 is all that's left but maybe you can re-evaluate if it's useful. i think it was just a convenience enhancement. i'm ok if you close this issue.
question - none of this new build stuff is included in 0.32.0 right ?
Correct, it's planned for the next one (0.33.0)