K
K
klinnov2016-08-23 11:05:41
JavaScript
klinnov, 2016-08-23 11:05:41

How to minify js files that are loaded via lazy load?

Through gulp, I connect and minify everything with bower_components and the main angular file - app.js into one file. Controllers, services and directives will be connected via lazy load depending on the route.
Example (from app.js):

/* Setup Rounting For All Pages */
TestApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
    // Redirect any unmatched url
    $urlRouterProvider.otherwise("/dashboard");

    $stateProvider

    // Dashboard
        .state('dashboard', {
            url: "/dashboard",
            templateUrl: "/app/src/views/dashboard/dashboard.html",
            data: {
                pageTitle: 'Admin Dashboard',
                breadcrumbs: 'Dashboard',
            },
            controller: "DashboardController",
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'TestApp',
                        files: [
                            '/app/src/controllers/dashboard/DashboardController.js',
                        ]
                    });
                }]
            }
        })
}]);

And so it turns out that controllers, services and directives are not minif. Is it possible to somehow minify them on the fly? Or as an option for the same controllers, put min.js copies and include them in resolve? And how then to generate them with gulp?
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question