LoginSignup
2
2

More than 5 years have passed since last update.

TypeScript x GulpでHello world

Last updated at Posted at 2015-04-11

リポジトリ準備

$ mkdir GulpTypeScript; cd GulpReactTypeScript
$ git init
$ npm init
$ npm install --save-dev gulp gulp-typescript

Gulpfile, index.html, index.tsを用意

gulpfile.js
'use strict';

var gulp = require('gulp');
var typescript = require('gulp-typescript');

gulp.task('build', function() {
  gulp.src('index.ts').pipe(typescript()).pipe(gulp.dest('.'));
});
index.html
<html>
  <head>
  </head>
  <body>
    <section id="hello-world"></section>
    <script src="index.js"></script>
  </body>
</html>
index.ts
// TypeScriptで書く意味ないけど
var elem = document.getElementById('hello-world');
elem.innerHTML = 'Hello, world!';

確認

$ gulp build
$ open index.html
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2