WebPACK中丑化导致路由停止工作 [英] Webpack Uglify causes routing to stop work
问题描述
在我丑化的WebPack包,路由将停止工作没有任何错误信息或日志信息。我使用oclazyload懒负载。
When I uglify webpack bundle, routing stops work without any error message or log message. I am using oclazyload to lazy load.
Route.js
module.exports = function(app) {
var routeConfig = function($stateProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'app/dashboard/dashboard.min.html',
title: 'Home',
ncyBreadcrumb: {
label: 'Home'
}
})
.state('organizationStructure', {
url: '/organizationStructure',
templateUrl: 'app/admin/organizationStructure/manageHierarchy/manageHierarchyShell.min.html',
'abstract': true,
ncyBreadcrumb: {
skip: true
},
resolve: ['$q', '$ocLazyLoad', function($q, $ocLazyLoad) {
var deferred = $q.defer();
require.ensure([], function() {
var mod = require('./organizationStructure.module.js');
$ocLazyLoad.load({
name: 'app.organizationStructure'
});
deferred.resolve(mod.controller);
});
return deferred.promise;
}]
})
.state('organizationStructure.organization', {
url: '/organization',
templateUrl: 'app/admin/organizationStructure/manageHierarchy/organization/index.min.html',
controller: 'ManageOrganization',
controllerAs: 'vm',
title: 'Manage Organization',
ncyBreadcrumb: {
label: 'Manage Organization',
parent: 'home'
}
});
}
app.config(routeConfig);
return routeConfig;
};
Module.js
var app = angular.module('app', [
'ui.router',
'restangular',
'ui.bootstrap',
'ncy-angular-breadcrumb',
'oc.lazyLoad'
]);
基本路线
require('./app.route.js')(app);
当我再缩小捆绑,应用路由停止工作。否则,它工作正常。请给我一个解决方案。另外我使用ngAnnotate。相关性在缩小的文件安全地注入。
When I minify the bundle, app routing stops working. Otherwise it works fine. Please provide me a solution. Also I am using ngAnnotate. Dependencies are injected safely in minified file.
推荐答案
您使用的是最新版本的UI路由器,它具有处理一个更新方式略有不同的解析
块。它需要一个对象映射。
You're using the latest version of ui-router, which has a newer and slightly different way of handling the resolve
block. It takes an object map.
试试这个:
resolve: {
foo: ['$q', '$ocLazyLoad', function($q, $ocLazyLoad) {
var deferred = $q.defer();
require.ensure([], function() {
var mod = require('./organizationStructure.module.js');
$ocLazyLoad.load({
name: 'app.organizationStructure'
});
deferred.resolve(mod.controller);
});
return deferred.promise;
}]
}
下面是这个UI路由器API文档: https://开头的github .COM /角度的UI / UI路由器/维基#决心
Here is the ui-router API doc for this: https://github.com/angular-ui/ui-router/wiki#resolve
这篇关于WebPACK中丑化导致路由停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!