18

GitHub - ioanungurean/forge-react-app: Start building scalable React apps using...

 5 years ago
source link: https://github.com/ioanungurean/forge-react-app
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Forge React App

Forge React App: React starter that uses TypeScript or ECMAScript bundled with Webpack 4 that has a highly scalable folder structure and a production build 5 times smaller than Create React App

Create React apps with no initial build configuration.

Forge React App works on macOS, Windows, and Linux.
If something doesn’t work, please file an issue.

Quick overview

npx forge-react-app my-app
cd my-app
npm start

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

Then open http://localhost:9000 to see your app.
When you’re ready to deploy to production, create a minified bundle with npm run build.

Creating an app

You’ll need to have Node >= 6 on your local development machine (but it’s not required on the server). You can use nvm (macOS/Linux) or nvm-windows to easily switch Node versions between different projects.

To create a new app, run a single command:

npx forge-react-app my-app

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

It will create a directory called my-app inside the current folder.
Inside that directory, it will generate the initial project structure and install the transitive dependencies:

.
├── devtools
│   └── webpack.config.js
└── src
    ├── components
    │   └── Title
    │       ├── test
    │       │   └── Title.test.tsx
    │       ├── Title.tsx
    │       └── Title.scss
    ├── favicon.ico
    ├── index.tsx
    ├── modules
    │   ├── App
    │   │   ├── App.tsx
    │   │   ├── App.scss
    │   │   └── test
    │   │       └── App.test.tsx
    └── ui
        ├── assets
        │   └── images
        └── shared
            ├── sizes.scss
            ├── colors.scss
            ├── normalize.scss
            └── shared.scss

Once the installation is done, you can open your project folder:

cd my-app

Inside the newly created project, you can run some built-in commands:

npm start or yarn start

Runs the app in development mode.
Open http://localhost:9000 to view it in the browser.

The page will automatically modify when you make changes to the code.
You will see the build errors and lint warnings in the console.

npm run test or yarn test

Runs the test watcher in an interactive mode.
By default, runs tests related to files changed since the last commit.

npm run build or yarn build

Builds the app for production to the public folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.

Your app is ready to be deployed.

npm run analyze or yarn analyze (Webpack Bundle Analyzer)

This script will help you:

  • Realize what's really inside your bundle
  • Find out what modules make up the most of it's size
  • Find modules that got there by mistake
  • Optimize it!
  • And the best thing is it supports minified bundles. It parses them to get real size of bundled modules. And it also shows their gzipped sizes.

Instructions for older npm versions

If you use npm 5.1 or earlier, you can't use npx. Instead, install forge-react-app globally:

npm install -g forge-react-app

Now you can run:

forge-react-app my-app

Main dependencies

Package Version Details React ^16.x

TypeScript ^3.x for TypeScript version Jest ^24.x

Enzyme ^3.x

Babel ^7.x for ECMAScript version Webpack ^4.x

Features

  • Scope Hoisting
  • Uglification of base app via webpack --mode production
  • Deterministic Hashes
  • Webpack Bundle Analyzer

Production build size

  • All (36.61 KB) (gzip)
    • vendor.a106ef9a79e0a54d062b.js (35.09 KB)
    • index.4bc3d8a674d7249b58c8.js (1.52 KB)

Feedback and suggestions

If you want to leave some suggestions or give me constructive feedback please don't hesitate to file an issue.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK