This is a starter template that includes the most efficient practices I've learned after struggling with the setup of React apps.
The project is designed to streamline development processes and exclude setup headaches, allowing developer to focus on building the application logic without worrying about the underlying infrastructure.
It's also recommended to maintain your own version of the template to ensure you have a reliable starting point for future React apps.
Additionally, the template comes with preconfigured settings, scripts, and folder structure that allows easy usage right out of the box.
Before getting started, make sure you have a package manager like npm installed on your machine
git clone <repository-url>
cd <project-name>
, then open it by running code .
npm install
to install dependenciesnpm run dev
to start the development serverAlternatively, you can download the project files by running the following command in your terminal:
npx degit AlexTsimba/react-ts-tailwind-boilerplate project-name
This template uses TailwindCSS as it's styling framework.
To fit the styles to your needs, modify the tailwind.config.cjs
file.
The tailwind-config-viewer
package is included to visually display the TailwindCSS configuration.
You can view the configuration by running the command npm run tailwind-viewer
.
Demo with default config
The classnames
package is included for conditional CSS rules.
import classNames from 'classnames';
classNames('foo', 'bar'); // => 'foo bar'
classNames('foo', { bar: true }); // => 'foo bar'
classNames({ 'foo-bar': false }); // => ''
classNames({ foo: true, bar: false }); // => 'foo'
For more information on how to use classnames, please read the official documentation
The following scripts are available for linting and formatting your code:
npm run lint
: Runs eslint to check for any syntax errors and coding style issues in your codenpm run format
: Formats your code using Prettier to ensure consistent and readable codenpm run fix-style
: Runs format
and lint --fix
sequentially to fix any formatting and style issues in your codeMake sure to have ESLint and Prettier plugins installed in your code editor to see linting and formatting errors and warnings. It's recommended to run these scripts frequently during development to ensure that your code meets the standards. Additionally, these scripts can be run automatically during your CI/CD pipeline to catch any issues before your code is deployed.
The project's GitHub Actions workflow automates the build and deployment process, triggered by a push event to the main
branch.
The workflow uses the peaceiris/actions-gh-pages
action for deployment,
pushing the production build files in ./dist
to the gh-pages
branch.
Before deploying, ensure you've granted permissions for workflows to run by setting it to. "Read and write" in Settings > Actions > General > Workflow permissions.
To enable automatic deployment to GitHub Pages, update the homepage
field in your package.json
file to your GitHub Pages site's URL.
// package.json
{
"name": "project-name",
"homepage": "https://my-username.github.io/project-name",
...
}
Also, make sure to update the base
field in vite.config.ts
// vite.config.ts
export default defineConfig({
base: '/project-name',
...
});
Manual deployment
In addition to the automated deployment process, you can also manually deploy your app's current version by executing the following command in your terminal:
npm run deploy
This command will initiate the build process and deploy the generated files to your GitHub Pages site, using the same configuration as the automated process.
Contributions are welcome! Here are some ways you can contribute:
This project is licensed under the MIT License.