We start by installing the dependencies that we need in this chapter using NPM:
npm init -y npm install react react-dom -save npm install gulp gulp-typescript small --save-dev
We set up TypeScript with lib/tsconfig.json
:
{ "compilerOptions": { "target": "es5", "module": "commonjs", "noImplicitAny": true, "jsx": "react" } }
We configure gulp in gulpfile.js
:
var gulp = require("gulp"); var ts = require("gulp-typescript"); var small = require("small").gulp; var tsProject = ts.createProject("lib/tsconfig.json"); gulp.task("compile", function() { return gulp.src(["lib/**/*.ts", "lib/**/*.tsx"]) .pipe(ts(tsProject)) .pipe(gulp.dest("dist")) .pipe(small("client/index.js", { externalResolve: ["node_modules"], outputFileName: { standalone: "client.js" } })) .pipe(gulp.dest("static/scripts/")); });
We install...