티스토리 뷰

개발../Node

gulp-typescript

링재호 2022. 5. 18. 13:24

gulp-typescript

gulp 를 이용하여 타입스크립트를 빌드하는 플러그인 입니다.

yarn add --save-dev typescript gulp gulp-typescript

gulpfile.js

타입스크립트를 빌드하기 위해 gulpfile.js 파일을 루트에 만들어줍니다.

import gulp from 'gulp';
import ts from 'gulp-typescript';
import concat from 'gulp-concat';

// tsconfig.json 에 정의한 옵션을 프로젝트로 리턴하여 사용합니다.
const tsCfg = ts.createProject('tsconfig.json');

// 아래와 같이 ts 를 js 로 컴파일 후, common.js 파일로 묶고 dist 폴더에 결과물이 저장됩니다.
gulp.task('merge', () => {
  return tsCfg.src()
    .pipe(tsCfg())
    .js.pipe(concat('common.js'))
    .pipe(gulp.dest('dist'));
});

tsconfig.json

간단한 tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "AMD",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": false,
    "declaration": true,
    "outDir": "./tsdist",
    "noImplicitAny": false
  },
  "include": ["src/*/*"],
  "exclude": ["node_modules"]
}

'개발.. > Node' 카테고리의 다른 글

cross-env  (0) 2022.09.26
yarn berry  (0) 2022.06.22
Node Sass version 7.0.0 is incompatible with ^4.0.0 || ^5.0.0 || ^6.0.0.  (0) 2022.03.14
Cannot find module '@babel/helper-builder-react-jsx'  (0) 2022.03.07
Webpack  (0) 2021.10.03
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/01   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함