This template aims to make it easier to create a modern Single-Page Application using good practices.
Good practices this repo provides:
- TypeScript
- TSLint
- Webpack
- React
- unit-testing with Jest and React Testing Library
- 3rd party dependencies loaded externally using a CDN
- easy local development
Install npm
using whatever
means is most convenient for you, such as Homebrew on macOS.
$ npm install
This creates a node_modules
directory.
$ npm test
$ npm start
And your browser will magically open to the web app. This supports hot-reloading, so feel free to edit Javascript and see your changes in the browser immediately.
The other way that works is to build the app explicitly (npm run build
), then
simply open index.html from the local filesystem in the browser.
Build:
$ npm run build
This will create web/app.bundle.js
.
Then upload the contents of web/
to your web host.
A non-traditional host that I really like, for its simplicity and speed, is Amazon S3 Static Website hosting.
Here is the Internet-hosted version of this project: http://philipmw-spa-template.s3-website-us-west-2.amazonaws.com/
Q: Why is source and tests in the same directory, as opposed to src/
vs test/
?
A: The pro is that it feels more natural to have tests next to source. It is also how the book I'm reading, Test-Driven React, does it. The con is that Tslint's configuration is a touch more complex, since I want to apply different line rules to source vs. test code, but the files are in the same directory.
I welcome your ideas and contributions. Please open an issue or submit a pull request.