I have a simple angular.js application that adheres to the best practices mentioned here.
angular
.module('myApp', ['ui.router']);
(function() {
function configureRoutes($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/404");
$stateProvider
.state('createCluster', {
url: '/create-cluster',
templateUrl: 'templates/create-cluster.html'
})
}
angular
.module('myApp')
.config(configureRoutes);
})();
I am using gulp to concatenate all JavaScript files, including angular-ui-router.js
, and then minify everything using uglify
. However, I encounter an issue when uglifying:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:unpr] Unknown provider: e
Removing the uglification resolves the issue. How can I prevent uglification from breaking ui-router?
Below is my current gulp
task:
gulp.task('uglify-js', function () {
gulp.src(['client/js/libraries/**/*.js', 'client/js/source/**/*.js'])
.pipe(concat('app'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(rename({ extname: ".min.js" }))
.pipe(gulp.dest('client/js'))'
});