ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Change name or location of lazy chunks #439

Open Vortilion opened 3 years ago

Vortilion commented 3 years ago

I am migrating an angularjs-app to angular by at first making it a hybrid application. Using AngularJS 1.6.4, Angular 12, ui-router and ocLazyLoad. There is one module which has to be loaded via lazyLoad after the user loggs in. I managed to achieve that with

`lazyLoad: ['$q', '$ocLazyLoad', function($q, $ocLazyLoad) { var deferred = $q.defer();

                // Async require => Split point - Webpack does split this into another bundle
                // TODO: Change secure-bundle's location to /secure
                require.ensure([], function () {
                    //
                    // All the code here, plus the required modules
                    // will be bundled in a separate file.
                    var module = require('../secure/config/app.secure.module.ajs');
                    //
                    // OCLazyLoad's 'load' function loads the Angular module.
                    $ocLazyLoad.load({
                        name: 'secure.module'
                    });

                    deferred.resolve(module);
                });
                return deferred.promise;
            }]`

The problem now is: I need to restrict access to this file via SpringSecurity (the frontend is embedded into a war file for a tomcat-server). Because depending on seperate angularCLI-build-configurations the name of the lazy chunk can be different, because it seems that by default it contains the relative-path to the secure-modules'-file in the filename ("frontend-srcapp_secure_config_app_secure_module_ajs_js"). So I would love to be able to change the lazy-chunks location and or filename from "/" to sth like "/secure". Is this somehow possible?