2012-11-06 4 views
3

저는 현재 Yeoman을 매우 사랑하고 있습니다. 내 각도 애플 리케이션을 잡고 그것을 serverless하게 할 수있는 작업이 있습니다. 기본적으로이 모든 템플릿을 잡아 지금 보좌관은 자신의 gruntfile을 가지고 있으며, 나는 궁금하네요 정도 그런트을 완전히 newb 해요
yeoman 빌드 프로세스

<script type="text/ng-template" id="dir to template"> ..template html goes here </script> 

와 index.html 파일에 삽입 의미
경우) 이것은 과잉 행동에 의해 처리되어야 하는가?
b) 기존의 툴팁 파일을 수정하거나 새 파일을 만들어야합니까?
c) 어떻게하는지에 대한 좋은 아이디어가 있습니까?

감사합니다.

답변

11

우리는 보좌관은 사용자 정의 할 수 있습니다 더 쉽게 만들기 위해 노력하고 있지만, 그 동안 당신이 당신의 Gruntfile이를 추가하여 build 작업을 재정의 할 수

grunt.renameTask('build', 'oldbuild'); 
grunt.registerTask('build', 'your-task oldbuild'); 

를 이것은 당신이에 원하는 작업을 추가 할 것 프로세스를 빌드합니다. 당신이 더 사용자 정의하려면


대신 build을 무시할 수하고 작업의 유사시에서 원하는 것을 함께 단지 조각 제공 : usemin-handler rjs concat css min img rev usemin manifest html합니다.

예 : 보좌관 빌드 프로세스를 사용자 정의 할 수없는 순간

grunt.registerTask('build', 'your-task rjs concat css whatever-you-want'); 
+0

옙이게 더 의미가 있습니다, 감사합니다 Sindre – climboid

0

. 그러나 해결 방법을 사용할 수 있습니다. 자신의 Gruntfile에 다음 코드를 복사 :

// Clobber the original targets 
var targets = { 
    // Add as many custom targets as you want, using custom modules, etc. 

    // Keep the existing targets 
    default : '    rjs concat css min img rev usemin manifest', 
    usemin : 'usemin-handler rjs concat css img rev usemin manifest', 
    text  : 'usemin-handler rjs concat css min  rev usemin manifest', 
    buildkit : 'usemin-handler rjs concat css min img rev usemin manifest html:buildkit', 
    basics : 'usemin-handler rjs concat css min img rev usemin manifest html:basics', 
    minify : 'usemin-handler rjs concat css min img rev usemin manifest html:compress', 
    test  : 'usemin-handler rjs concat css img rev usemin manifest', 

    yourbuild : 'intro clean mkdirs rjs' 
}; 

// If we clobber targets, we have to rebuild targetList, the below is copy paster from Yeoman.js 
var targetList = grunt.log.wordlist(Object.keys(targets)); 

// We also have to rebuild the build task with the new targetList 
grunt.registerTask('build', 'Run a predefined target - build:<target> \n' + targetList, function(target) { 
    var valid = Object.keys(targets); 
    target = target || 'usemin'; 

    if (valid.indexOf(target) === -1) { 
     grunt.log 
     .error('Not a valid target') 
     .error(grunt.helper('invalid targets', targets)); 
     return false; 
    } 

    var tasks = ['intro', 'clean coffee compass mkdirs', targets[target], 'copy time'].join(' '); 

    // Now overwrite the task for our costume build 
    if(target === 'yourbuild') { 
     tasks = targets[target]; 
    } 

    // Conditionally remove compass/manifest task if either compass or 
    // phantomjs binary is missing. Done only for `test` target (specifically 
    // used for our `npm test`). For each, output warning infos. 
    if(target === 'test') { 
     tasks = grunt.helper('build:skip', tasks, 'compass'); 
     tasks = grunt.helper('build:skip', tasks, 'phantomjs', 'manifest'); 
    } 

    grunt.log.subhead('Running ' + target + ' target') 
    .writeln(' - ' + grunt.log.wordlist(tasks.split(' '), { separator: ' ' })); 

    grunt.task.run(tasks); 
}); 

지금 당신이 당신의 자신의 빌드 프로세스 사용자 정의 다음 줄을 변경할 수 있습니다

yourbuild : 'intro clean mkdirs rjs' 

하지만 기억하시기 바랍니다,이 코드는 유사시에서 복사 입니다 출처이고 업데이트 된 경우 직접 혼자해야합니다.

+0

와우 이것은 최고입니다. 고맙습니다 netzzwerg, 슈퍼 유용한. – climboid

+1

내부 코드를 복제하는 것은 방법이 아니며 나중에 언젠가는 코드를 깨뜨릴 것입니다. 당신이 똑같이 달성 할 수있는 또 다른 방법을 반영하여 나의 대답을 업데이트했습니다. –