<<<<<<< HEAD
A boilerplate for TypeScript projects.
- Out-of-box configuration
- http server:
express.js - browser bundling:
webpack, with hot module replacement (HMR) - test:
jest(test runner) /chai(assertion) - lint:
tslint
- http server:
- Latest packages
- TypeScript v2.6
- webpack v3.8
- express.js v4
- Variants for different JavaScript environments: node.js / browser / Electron
- see Variants for details
- CI Integration
- Can be easily adapted to more JavaScript runtimes
- Electron / ReactNative / you name it
master branch. All other variants are based on this.
- TypeScript compiler:
- compile to ES6 for server
- compile to ES5 code for browser (while using ES6 module to enable webpack tree-shaking)
- webpack
- 2 configurations:
dev(with hot reload) /prod(with code compression) - configured with TypeScript (
ts-loader) - hot module reload
- include browser polyfill
corejs
- 2 configurations:
- no frontend framework included
- a full-featured dev server that reloads
- npm scripts to build and run
- see Built-in npm scripts for details
Directories:
lib/ compiled JavaScript code
lib-ts/ TypeScript code
server/ server-specific
browser/ browser-specific
common/ code shared by server / browser
public/ static assets: JS bundles, images, etc
webpack/ webpack configuations
(my) Develop conventions:
- TS only, when writing code:
- run and auto-restart server with
ts-node-dev - serve browser bundles with
webpack-dev-middleware
- run and auto-restart server with
- Compile to JS before deploy:
- one can also simply
npm run build && npm run webpack:prod && git commitandgit pullin server - a good time to do this would be during
docker build
- one can also simply
- JS only (this includes server code and static assets), when running in production server
webpack-react branch. Contains a frontend-only React app.
webpack-preact branch. Contains a frontend-only Preact app.
Preact is a Fast 3kB alternative to React (v15 as of now) with the same ES6 API.
A full-featured http server that reloads when possible, most useful when writing code.
- execute server code with
ts-nodeandts-node-dev, restarts on code change. - build and serve webpack bundle with
webpack-dev-middleware, with HMR- try it: open
http://localhost:9000/and modifylib-ts/browser/m.ts - note: currently server restart does not cause page to reload
- try it: open
- serve static assets
- can also be a startpoint of complete app server (it is but a
express.jsapp)
$ npm run dev-server# compile lib-ts/ to lib/
$ npm run build
# compile while watching
$ npm run build:watch
# run lib-ts/server-main.ts with ts-node
$ npm run start:ts
# run lib/server-main.js with node
$ npm run startIn all configurations, webpack bundle will be written to public/static/browser-entrypoint.js
# create dev bundle
$ npm run webpack
# create dev bundle, and update when file changes
$ npm run webpack:watch
# create minimized production bundle
$ npm run webpack:prod# run tslint
$ npm run tslint
# let tslint fix simple warnings
$ npm run tslint:fix
# run test suites ()
$ npm run test
# re-run test suites when code changes
$ npm run test:watch
# generate coverage report in /coverage/
$ npm run test:coverage(Variants may have more npm scripts, please refer to their README.md as well.)
bd260613754c5d8832eccd6c7e7e21858df00e3a