DEV Community

Deependra Singh
Deependra Singh

Posted on

๐Ÿš€ I Built a CLI to Create SPFx Projects with Tailwind CSS Pre-Configured!

๐Ÿ‘‹ Introduction

If you've worked with SharePoint Framework (SPFx), you probably know that setting up a new project and configuring your preferred styling tools can take some extra time.

I personally enjoy working with Tailwind CSS because it makes styling React components faster, cleaner and more consistent.

But I wanted to make the initial setup easier.

So, I decided to build something of my own: a CLI tool that helps developers create SPFx projects with Tailwind CSS pre-configured! ๐ŸŽ‰

In this article, I'll walk you through the idea, installation process and how to get started.

๐Ÿค” Why Did I Build This?

Every time we start a new project, we often repeat similar configuration steps.

For developers who prefer Tailwind CSS, this can mean:

  • Installing and configuring dependencies.
  • Setting up Tailwind CSS.
  • Configuring the build environment.
  • Making sure everything works with SPFx.
  • Repeating these steps for every new project.

I wanted to reduce this repetitive work.

The idea was simple:

โšก One command. A ready-to-use SPFx project. Less time configuring, more time building!

๐Ÿ› ๏ธ Introducing create-spfx-tailwind-app

Meet my CLI tool:

create-spfx-tailwind-app

It helps developers create SPFx projects with Tailwind CSS pre-configured.

Instead of starting with a blank project and repeating the styling configuration, you can get started using a single command.

๐Ÿš€ Getting Started

Step 1: Create your project

Open your terminal and run:

npx create-spfx-tailwind-app MyProject
Enter fullscreen mode Exit fullscreen mode

That's it! Your project creation process begins.

Step 2: Navigate to your project

Once the project has been generated:

cd MyProject
Enter fullscreen mode Exit fullscreen mode

Follow the installation instructions provided by the generated project to install dependencies.

Step 3: Start exploring!

Open the project in your preferred code editor and explore the generated structure.

๐ŸŽจ Why Tailwind CSS with SPFx?

Tailwind CSS follows a utility-first approach to styling.

Here are some reasons I like using it:

Benefit Why it matters
โšก Faster development Style components using utility classes
๐ŸŽฏ Consistency Maintain a consistent design system
๐Ÿ“ฑ Responsive UI Build responsive layouts easily
๐Ÿงฉ Reusability Create reusable React components
๐Ÿงน Less custom CSS Reduce the need for separate CSS rules

For example, instead of writing separate CSS rules:

.card {
  padding: 20px;
  background-color: #ffffff;
  border-radius: 12px;
}
Enter fullscreen mode Exit fullscreen mode

You can use Tailwind utility classes directly in JSX:

<div className="rounded-xl bg-white p-5 shadow-md">
  <h2 className="text-xl font-bold text-gray-800">
    Hello SharePoint!
  </h2>
</div>
Enter fullscreen mode Exit fullscreen mode

Simple, readable and convenient! โœจ

๐Ÿ‘จโ€๐Ÿ’ป Who Can Benefit From This?

This CLI can be useful for:

  • SPFx developers who prefer Tailwind CSS.
  • React developers building SharePoint solutions.
  • Developers starting new SPFx projects.
  • Developers who want to simplify repetitive setup tasks.

๐Ÿ”ฎ What's Next?

This is just the beginning!

I want to continue improving the CLI, make the setup experience smoother and explore more ways to simplify SPFx development.

I'm also interested in hearing feedback from other developers.

If you try it, let me know what you think!

๐Ÿค Let's Connect!

If you're working with SharePoint, SPFx, React or Microsoft 365, I'd love to connect with you.

You can explore my work and follow my development journey here:

๐ŸŽฏ Final Thoughts

This project started with a simple thought: why spend time repeating configuration steps when we can automate them?

Building this CLI gave me an opportunity to explore developer tooling and make something that could help other developers.

Keep learning. Keep building. Keep sharing! ๐Ÿš€

Thanks for reading! โค๏ธ

If you found this useful, consider leaving a comment or sharing your feedback.


Tags

sharepoint spfx tailwindcss typescript opensource

Top comments (0)