Welcome to the StartOut React project. This project is set up with a comprehensive configuration including Prettier, ESLint, Tailwind CSS, and a sample folder structure to get you started quickly.
Here is an overview of the folder structure in this project:
.
├─ public
│ └─ favicon.ico
├─ src
│ ├─ assets
│ ├─ components
│ │ ├─ footer
│ │ │ └─ footer.jsx
│ │ ├─ header
│ │ │ └─ header.jsx
│ ├─ pages
│ │ ├─ landing
│ │ │ └─ landing.jsx
│ │ ├─ error404
│ │ │ └─ error404.jsx
│ ├─ redux
│ ├─ exports.js
│ ├─ App.js
│ ├─ index.js
│ └─ index.css
├─ .env
├─ .eslintrc.json
├─ .gitignore
├─ .prettierignore
├─ .prettierrc
├─ package.json
├─ postcss.config.cjs
├─ tailwind.config.js
└─ README.md
- public/: Contains static assets such as the favicon.
- src/: Main source directory for the project.
- assets/: Contains images, fonts, and other static assets.
- components/: Contains reusable React components.
- header/: Header component (
header.jsx). - footer/: Footer component (
footer.jsx).
- header/: Header component (
- pages/: Contains page components.
- landing/: Landing page component (
landing.jsx). - error404/: 404 error page component (
error404.jsx).
- landing/: Landing page component (
- redux/: Contains Redux related files (if applicable).
- exports.js: Exports file for centralizing component exports.
- App.js: Main App component which sets up the router.
- index.js: Entry point for React DOM rendering.
- index.css: Main CSS file, configured to use Tailwind CSS.
- .env: Environment variables.
- .eslintrc.json: ESLint configuration file.
- .gitignore: Specifies intentionally untracked files to ignore.
- .prettierignore: Specifies files and directories to ignore by Prettier.
- .prettierrc: Configuration file for Prettier.
- package.json: Lists project dependencies and scripts.
- postcss.config.cjs: Configuration file for PostCSS.
- tailwind.config.js: Configuration file for Tailwind CSS.
- README.md: This file.
First, clone the repository and install the dependencies:
git clone https://github.com/yourusername/startout-react-app.git
cd startout-react-app
npm installThis script automates the setup of a new React project, optionally including TypeScript. It installs necessary dependencies, configures Prettier and ESLint, adds useful scripts to package.json, and sets up Tailwind CSS. It also organizes the project structure by creating directories and files for components, assets, and pages.
- Node.js and npm must be installed on your machine.
- TypeScript Support: Optionally creates a TypeScript-based project.
- Tailwind CSS Setup: Integrates Tailwind CSS.
- Prettier Configuration: Sets up Prettier for code formatting.
- ESLint Configuration: Configures ESLint for linting based on best practices and integrates with Prettier.
- Directory Structure: Automatically creates directories and files for a standard project setup.
- Routing: Configures react-router-dom for routing in the application.
- Scripts for Linting and Formatting: Adds custom scripts for linting and formatting to
package.json.
-
Make the script executable:
chmod +x setup_react.sh -
Execute the script:
./setup_react.sh
The script uses the following environment variables to customize the project setup (more will be added in the future):
MODULE_REACT_APP_NAME: Sets the application name (default:startout-react-app).MODULE_REACT_USE_TYPESCRIPT: Enables TypeScript if set to true (default: false).
To start the development server: npm start
This will run your app in development mode. Open http://localhost:3000 to view it in the browser.
To build the app for production:npm run build
This will create an optimized build of the app in the build folder.
To check for code quality issues: npm run lint
To format the code: npm run format
This project comes with a set of predefined configurations for ESLint, Prettier, and Tailwind CSS. You can customize these configurations by editing their respective files:
.eslintrc.json.prettierrctailwind.config.jspostcss.config.cjs
- Pages: Add new page components in the
src/pagesdirectory. Follow the existing structure for consistency. - Components: Add reusable components in the
src/componentsdirectory.