Gulp "Hello World" 출력

1 개념[ | ]

"Hello World" 출력
  • gulp로 "Hello World" 출력

2 예시 1[ | ]

  • gulpfile.js 파일 준비
var gulp = require('gulp');

gulp.task('hello', function() { 
    return console.log("Hello World");
});
1) gulp.task는 gulp task를 등록해주는 메쏘드
2) hello이름을 가진 task가 등록이 되었으며 실제 수행 함수는 "Hello World"를 출력함
  • 실행
$ gulp hello
[21:24:42] Using gulpfile gulpfile.js
[21:24:42] Starting 'hello'...
Hello World
[21:24:42] Finished 'hello' after 109 μs

3 예시 2[ | ]

커멘드 라인에서 gulp만 입력하여 실행하는 방법
  • gulpfile.js 파일 준비
var gulp = require('gulp');

gulp.task('hello', function() {
        return console.log("Hello World");
});

gulp.task('default', ['hello']);
1) default task를 추가
2) default task에 hello task를 배열로 추가
  • 실행
johnjeong@JohnJeong4p:~/workspace/test$ gulp
[21:49:12] Using gulpfile ~/workspace/test/gulpfile.js
[21:49:12] Starting 'hello'...
Hello World
[21:49:12] Finished 'hello' after 161 μs
[21:49:12] Starting 'default'...
[21:49:12] Finished 'default' after 7.37 μs
1) task명 없이 gulp 명령만으로 실행
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}