2011-11-21 3 views
1

저는 RequireJS를 기반으로하는 앱에 테스트 통합을 조사했습니다. 나는 QUnit 테스트가 RequireJS 구조에 어떻게 통합 될 수 있는지를 this example 발견했습니다. 분명히 테스트 코드가 프로덕션 빌드에 누우 길 원치는 않습니다. RequireJS의 최종 생산 빌드에서 테스트를 어떻게 유지할 수 있습니까?RequireJS - 최적화 된 빌드에서 테스트 코드 생략

답변

2

빌드 파일에서 설정할 수있는 옵션이 많이 있습니다. GitHub의에 전체 예를 참조 (https://github.com/jrburke/r.js/blob/master/build/example.build.js)

당신이 당신의 모듈에서 특정 항목 제외되고 싶지 :

//This module entry combines all the dependencies of foo/bar/bip into one file, 
//but excludes foo/bar/bop and its dependencies from the built file. If you want 
//to exclude a module that is also another module being optimized, it is more 
//efficient if you define that module optimization entry before using it 
//in an exclude array. 
    { 
     name: "foo/bar/bip", 
     exclude: [ 
      "foo/bar/bop" 
     ] 
    }, 

//This module entry shows how to specify a specific module be excluded 
//from the built module file. excludeShallow means just exclude that 
//specific module, but if that module has nested dependencies that are 
//part of the built file, keep them in there. This is useful during 
//development when you want to have a fast bundled set of modules, but 
//just develop/debug one or two modules at a time. 
    { 
     name: "foo/bar/bin", 
     excludeShallow: [ 
      "foo/bar/bot" 
     ] 
    } 

당신은 또한 정규 표현식으로 항목을 제외 할 수 있습니다, 그러나 이것은 과잉 아마도 :

//When the optimizer copies files from the source location to the 
//destination directory, it will skip directories and files that start 
//with a ".". If you want to copy .directories or certain .files, for 
//instance if you keep some packages in a .packages directory, or copy 
//over .htaccess files, you can set this to null. If you want to change 
//the exclusion rules, change it to a different regexp. If the regexp 
//matches, it means the directory will be excluded. This used to be 
//called dirExclusionRegExp before the 1.0.2 release. 
//As of 1.0.3, this value can also be a string that is converted to a 
//RegExp via new RegExp(). 

fileExclusionRegExp: /^\./, 
+0

fileExclusionRegExp는 실제로 CoffeeScript를 JS로 컴파일하고 컴파일 된 디렉토리에 .coffee 파일이 필요없는 경우에 매우 유용합니다. – Daniel