I know there are solutions out there to retrieve via javascript using System.import
, however I want to use the directive version so we don't have to create a controller for every single template.
What I'm trying to achieve is extracting a list of all files sent as an entry file, with a specific extension, and get their bundled name.
Let's say I have 3 files for simplicity:
module-a.lazy.js
module-b.lazy.js
main.entry.js
Let's say my entry points and output are defined like so:
var config = {
entry: {
module-a: "./module-a.lazy.js",
module-b: "./module-b.lazy.js",
bundle: "./main.entry.js"
},
output: {
filename: "[name]-[hash:4].js",
path : '/build'
}
}
Obviously I'm going to end up with 3 files in my build folder, each with a custom dynamic hash in it's filename which i cannot type into the ocLazyLoad directive.
In the main.entry.js file, I have a constant setup, which I'd like to replace with the output names of the lazy files.
angular.module('demo', [])
.constant('lazies', '%lazyfilenamehere%');
Expected output would be something like this:
angular.module('demo', [])
.constant('lazies', ['/build/module-a.lazy-af34.js','/build/module-b.lazy-fdg3.js']);
Once I can obtain the output path names and store them in the main bundle, I can easily decorate the original ocLazyLoad directive to first search this array by a partial string, when matched it can return the whole filename and request it as normal.