Skip to content

fretchen/fretchen.github.io

Repository files navigation

Nano React App Default Typescript Template

The default template project for nano-react-app.

  • npm start — This will spawn a development server with a default port of 3000.
  • npm run build — This will output a production build in the dist directory.
  • npm run preview — This will run the production build locally with a default port of 5173 (this will not work if you haven't generated the production build yet).
  • npm run typecheck — This will run tsc --noEmit which basically just typechecks your project.
  • npm run typewatch — This will run tsc --noEmit --watch which will typecheck your project as you make changes.

Typechecking

Unfortunately, ViteJS does not perform typechecking. So you will need to make use of the typecheck and typewatch scripts above.

Custom port

You can use the -p flag to specify a port for development. To do this, you can either run npm start with an additional flag:

npm start -- --port 1234

Or edit the start script directly:

vite --port 1234

Adding styles

You can use CSS files with simple ES2015 import statements anywhere in your Javascript:

import "./index.css";

Babel transforms

The Babel preset babel-preset-nano-react-app is used to support the same transforms that Create React App supports.

The Babel configuration lives inside package.json and will override an external .babelrc file, so if you want to use .babelrc remember to delete the babel property inside package.json.

Deploy to GitHub Pages

You can also deploy your project using GitHub pages. First install the gh-pages package:

npm i -D gh-pages

With Parcel's --public-url flag, use the following scripts for deployment:

"scripts": {
  "start": "vite",
  "build": "vite build",
  "predeploy": "rm -rf dist && vite build",
  "deploy": "gh-pages -d dist"
},

Then follow the normal procedure in GitHub Pages and select the gh-pages branch.