우리는 별도의 JavaScript 파일을 많이 가지고 있으며, 물론 Production의 다양한 다른 파일로 축소되었습니다. 현재이 작업에 대해 명령 줄에서 Microsoft Ajax Minifier을 사용하지만 gulpjs으로 전환합니다.Gulp가 js 오류를 던졌습니다.
괜찮을을듯한 축약 과정 자체가, 모든 출력 파일이 오류가 출력에 기록되지 않으며, 생성 등
하지만 이상한 문제가, 16 중 ~ 4-5 축소 된 gulpjs
에 의해 생성 된 파일은 다음과 같은 여러 가지 오류를 던져 :
Cannot read property '...' of undefined
또는
Uncaught TypeError: (intermediate value)(intermediate value)(...) is not a function
아약스 마일 minify.xml
에서
AjaxMin.exe -js -xml .\minify.xml -clobber -evals:safeall
샘플을 : 다음과 같이 nifier가 호출됩니다
<?xml version="1.0" encoding="utf-8"?>
<root>
<output path="..\js\min\main.min.js">
<input path="..\js\filename1.js"/>
<input path="..\js\filename2.js"/>
<input path="..\js\filename3.js"/>
...
</output>
<output path="..\js\min\report.min.js">
<input path="..\js\filename4.js"/>
<input path="..\js\filename5.js"/>
<input path="..\js\filename6.js"/>
...
</output>
...
</root>
가 중요한 경우
gulp.task("[js]minify-all", function() {
var mainFiles = [
"./js/filename1.js",
"./js/filename2.js",
"./js/filename3.js",
];
var reportFiles = [
"./js/filename4.js",
"./js/filename5.js",
"./js/filename6.js",
];
...
generateMinifiedFile(mainFiles, "./js/min/", "main");
generateMinifiedFile(reportFiles, "./js/min/", "report");
...
}
var generateMinifiedFile = function(inputFiles, outputPath, outputFileName) {
gulp.src(inputFiles)
.pipe(concat(outputFileName + ".js"))
.pipe(minify({
ext: {
min: ".min.js"
},
noSource: true
}))
.pipe(gulp.dest(outputPath));
};
gulpfile.js
에서 샘플, 여기 package.json
{
"name": "package",
"version": "1.0.0",
"private": true,
"devDependencies": {
"gulp": "3.9.1",
"gulp-bower": "0.0.13",
"gulp-concat": "^2.6.0",
"gulp-config": "0.3.0",
"gulp-less": "3.0.5",
"gulp-minify": "0.0.12",
"gulp-minify-css": "1.2.4",
"gulp-plumber": "1.1.0",
"gulp-watch": "4.3.5"
}
}
,
총계 :
- 축소되지 않은 js 파일을 사용하면 사이트가 정상적으로 작동합니다.
AjaxMin.exe
으로 작성된 축소 된 js 파일을 사용하면 사이트가 정상적으로 작동합니다.gulpjs
으로 만든 축소 된 js 파일을 사용하면 사이트가 손상됩니다.
누구나 내가 놓친 제안이 있으십니까?
var settingsModule = angular.module("settingsModule", ["rootModule"]);
settingsModule.controller('settingsCasesController', ["$rootScope", "$scope", "$http", "DataService", function ($rootScope, $scope, $http, dataService) {
...
}
귀하의 소스에 Angular가있을 수 있습니까? –
@IlyaNovojilov 예, 각도 파일은 페이지의 직접 참조이므로 어떤 출력 파일로도 축소되지 않습니다. – Szeki
각도 지시문을 축소합니까? 그렇다면 http://stackoverflow.com/questions/18782324/angularjs-minify-best-practice –