나는 jshint/uglify와 grunt로 작업 한 처음으로 이것이주의해야 함에도 불구하고 여기에서 사냥하고 상당히 긴 Google 검색을 통해 명백한 것을 볼 수 없었습니다. .grunt : jshint uglify 경고 발생 후
I가 2 테스트 JS 파일 (간결성의 이익을 위해) :
(function() {
console.log("I'm in your build, testing your stuff (1)");
})();
및
(function() {
console.log("I'm in your build, testing your stuff (2)");
})();
내 툴툴 거리는 소리 파일 빌드 작업의 수는 않지만, 기본적으로 내가 두 번 jshint를 실행 - 한 번 src (문제가있는 경우 일찍 중지) 및 모든 concat/uglify 후에 최종 파일 출력이 계속 전달되는지 확인하십시오.
소스 위의 jshint는 치료를 처리하지만 uglify가 몇 개의 세미콜론을 제거했기 때문에 jshint post 'build'가 실패한 것으로 보입니다.
(참고 용) 내 툴툴 거리는 소리 파일의 관련 부분 :
jshint: {
jshintrc: '.jshintrc',
source: {
files: {
src: ['app/common/scripts/**/*.js',
'app/games/**/*.js'
]
}
},
dist: {
files: {
src: [ 'dist/' + targetEnvironment + '/common/scripts/**/*.js',
'dist/' + targetEnvironment + '/games/**/*.js'
]
}
}
},
concat: {
scriptsCommon: {
src: [ 'app/common/scripts/*.js',
],
dest: 'dist/' + targetEnvironment + '/common/scripts/common.concat.js',
nonull: true
}
},
uglify: {
all: {
files: [
{ src: 'dist/' + targetEnvironment + '/common/scripts/common.concat.js',
dest: 'dist/' + targetEnvironment + '/common/scripts/common.min.js' },
]
}
}
및 실행 내 고된 작업이 본질적으로 (다시, 예를 들어 삭감) :
grunt.registerTask('default', [
'jshint:source',
'concat:scriptsCommon',
'uglify:all',
'jshint:dist'
jshint:source
작품 대접, jshint:dist
은 세미콜론 누락에 대해 불평하지 않습니다. (참조)
uglify'd 스크립트입니다 :
당신이 볼 수 있듯이, CONSOLE.LOG 문이 모두 있었다!function(){"use strict";angular.module("TestingStuffs",[]).controller("TestController",["$http","$log",function(){}]).controller("Test2Controller",["$http","$log",function(){}])}(),function(){console.log("I'm in your build, testing your stuff (1)")}(),function(){console.log("I'm in your build, testing your stuff (2)")}();
자신의 세미콜론의 제거 - 안전하게 보인다. 왜 uglify가이 작업을 수행했는지 이해할 수 있습니다. 또한 jshint가 그것에 대해 불평하는 이유를 이해할 수 있습니다.
이상적으로는 uglify를 수정하여 세미콜론을 남겨두기를 원합니다. (비록 세미콜론 경찰이 싫어할 지 모르지만) 이상적으로는 jshint를 무시하는 옵션을보고 싶습니다. 세미콜론 문제는 물론 uglify로 남겨 둡니다.
감사의 말에 감사드립니다.
건배, 테리