Minifying AngularJS application issues

2019-08-26 07:40发布

I have an application written in AngularJS and Bootstrap that works perfectly well, but when I tried to minify it I got problems.

The index.html of my app is:

<!DOCTYPE html>
<html lang="es-ES"  >
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Vebor Editor</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">


    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<link rel="stylesheet" href="css/style.min.css">

</head>
    <body ng-app="editor"  ng-strict-di>
        <header ng-include="'views/header.html'"></header>
        <div class="container">
            <div ui-view></div>
        </div>
        <footer class="footer" ng-include="'views/footer.html'"></footer>
<script src="/lib/angular/angular.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-route.min.js"></script>
        <script src="https://cdn.rawgit.com/angular-ui/ui-router/0.2.18/release/angular-ui-router.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-resource.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-animate.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-aria.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-messages.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-sanitize.min.js"></script>
        <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
        <script src="/js/scripts.min.js"></script>
    </body>
</html>

I have 14 different js files so I won`t copy them here, if there is anything you need let me know. The main js file is something like this:

(function(){

    'use strict';
    angular.module('editor', [
        'ngMaterial', 'ngRoute',  'ngSanitize', 'ui.bootstrap', 'ui.router',
        'editor.mainControllers', 'editor.searchControllers', 'editor.classControllers', 'editor.contactController', 'editor.viewerController', 'editor.listingControllers',
        'editor.services', 'editor.serverCallsServices', 'editor.translationService'
    ]);
function config (...){...}
function run(...){...}
})();

First, I used the function uglify in gulp in order to generate the distribution project with style.min.css and script.min.js.

Second, I manually copy the whole content of my js files into one unique script.js and then I minified it using external tools. (The problems I got happended even with the unified file without being minified).

Problem

The problem is simple to explain. The page is not loaded, it seems like an infinite loop because the console shows nothing and there is no DOM. If I reload the page it's still not working, I have to close the tab and open it again.

Due to the fact that there is no information from the brower, I'm very lost. Do you know why this might be happending? Or maybe there is something that I could use to try to discover the problem?

I've already know about the injection problem in Angular and I have all my controllers with the proper $inject.

1条回答
对你真心纯属浪费
2楼-- · 2019-08-26 07:54

If I was you I would try to load the files in different order.

This answer could helps you.

查看更多
登录 后发表回答