使用grunt concat和uglify进行角度app的代码缩小

时间:2016-12-10 09:35:55

标签: angularjs minify grunt-contrib-uglify grunt-contrib-concat

我正在使用grunt concat和uglify来缩小角度app,但是缩小的脚本会出现以下错误。

  

未捕获错误:[$ injector:modulerr]   http://errors.angularjs.org/1.5.9/ $注射器/ modulerr P0 = MYAPP&安培; P1 =错误%... 2F%2F192.168.1.244%3A8080%2Fapp%2Fdist%2Fjs%2Fmyapp.min.js%3A5%3A10649)(...)

这就是我在角度应用程序中实现DI的方法。

(function() {
    myapp
    
    .controller('MyController',MyController);

    MyController.$inject = ['$scope','$rootScope'];
	
    function MyController($scope,$rootScope) {
      
    }
})();

这就是我的gruntfile的样子。

module.exports = function(grunt) {
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		concat: {
			dist: {
				src: ['node_modules/jquery/dist/jquery.min.js','node_modules/bootstrap/dist/js/bootstrap.min.js','node_modules/angular/angular.min.js'],
				dest: 'dist/js/myapp.js',
			}
		},
	 	uglify: {
			options: {
				report: 'min',
				mangle: false
			},
			my_target: {
				files: {
					'dist/js/myapp.min.js':['dist/js/myapp.js']
				}
			}
		}
	});
	
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
};

我正在遵循正确的角度DI方法,为什么错误仍然存​​在?

0 个答案:

没有答案