https://pandao.github.io/editor.md/en.html#%F0%9F%91%89%20Step%205%20Install%20Tailwind%20CSS%20with%20Parcel

TOCHECK pnpm list --depth=0 pnpm list --depth -1

Completed

πŸ‘‰ Step 7: Create Second SGS project

🏠 Select root folder

Monorepo Setup Notes

πŸ‘‰ Step 1: Create Root-Level Setup

🏠 Select root folder

Establish a common root so all projects (apps, packages, shared code) that can work under one workspace using PNPM.

Home directory (root of the workspace) for this setup:

πŸ“‚ D:\WorkArea\Projects\

🧩 Initialize Workspace Root

As per the planned folder structure, the root of the workspace is:

D:\WorkArea\Projects\

πŸ“¦ Install pnpm package

Install pnpm globally 🌐, that replaces npm

> npm install -g pnpm

Infact it is not a replacement, but you can use npm simultaniously You’ll use pnpm install, pnpm run, pnpm add, etc. instead of npm equivalents.

πŸ“¦Initialize pnpm

Open a terminal πŸ’» and navigate to the root folder

> cd D:\WorkArea\Projects\React

πŸš€ Run this command inside root folder.

> pnpm init

It will create a package.json that looks something like this:

{ "name": "projects", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "packageManager": "pnpm@10.7.1" }

Although it created the default package.json, some entries can be removed to keep it miminal.

🧹 Suggested Cleaned-Up Version:

{ "name": "projects", "version": "1.0.0", "description": "Root of the React monorepo", "scripts": {}, "license": "ISC", "packageManager": "pnpm@10.7.1" }

Note: This package.config is only for managing the workspace β€” not an app

🧠 Why This Step:

βœ… Recommended Minimal Changes for Monorepo Root

Field Keep/Delete? Why / Notes
"name" βœ… Keep Name is fine, can even be lowercase like "projects"
"version" βœ… Keep Versioning is fine, not used at the root for your case
"description" 🟑 Optional You can leave blank or write β€œMonorepo root” for clarity
"main" ❌ Delete Not needed for monorepo root; root isn’t an importable package
"scripts" βœ… Keep/edit You can delete the "test" script or leave it for now
"keywords" 🟑 Optional Not needed unless you want to document metadata
"author" 🟑 Optional Your name here, for documentation only
"license" βœ… Keep ISC is fine, or you can change based on your needs
"packageManager" βœ… Keep PNPM adds this automaticallyβ€”helps ensure consistent package manager usage

Now the folder structure looks like this:

D:\WorkArea\Projects\ β””β”€β”€πŸ“¦ package.json ← πŸ“Œ Root of workspace

Finalize PNPM Setup at root folder

Open a terminal πŸ’» and navigate to the root folder

> cd D:\WorkArea\Projects\React

πŸš€ Run this command inside root folder.

> pnpm install

Now, PNPM will automatically:

This detects all package.json files in the defined workspace (There is only one in root now)

Now the folder structure looks like this:

D:\WorkArea\Projects\ β”œβ”€β”€πŸ“ node_mdules/ πŸ‘ˆ New folder β”œβ”€β”€πŸ“¦ package.json β””β”€β”€πŸ› οΈ+πŸ”’ pnpm-lock.yaml πŸ‘ˆ New file

✨ TL;DR

Home directory (root of the workspace) for this setup:

Path: πŸ“‚ D:\WorkArea\Projects\

> npm install -g pnpm

> cd D:\WorkArea\Projects\React

> pnpm init

It will create a package.json and the folder structure looks like this:

D:\WorkArea\Projects\ β””β”€β”€πŸ“¦ package.json ← πŸ“Œ Root of workspace

> pnpm install

Now the folder structure looks like this:

D:\WorkArea\Projects\ β”œβ”€β”€πŸ“ node_mdules/ πŸ‘ˆ New folder β”œβ”€β”€πŸ“¦ package.json β””β”€β”€πŸ› οΈ+πŸ”’ pnpm-lock.yaml πŸ‘ˆ New file

πŸ‘‰ Step 2: Create Workspace Folder Structure

Before configuring the workspace, a minimal workspace structure is created.

2.1 Create Workspace Folder Structure

Ceate following folder structure under root folder D:\WorkArea\Projects\

D:\WorkArea\Projects\ β”œβ”€β”€πŸ“ node_mdules/ β”œβ”€β”€πŸ“ frontend/ πŸ‘ˆ New folder β”‚ β”œβ”€β”€πŸ“ apps/ πŸ‘ˆ New folder β”‚ β”œβ”€β”€πŸ“ packages/ πŸ‘ˆ New folder β”œβ”€β”€πŸ“¦ package.json β””β”€β”€πŸ› οΈ+πŸ”’ pnpm-lock.yaml

🧠 Why This Structure:

Folder Purpose
apps/ For apps or demo projects. Keeps them separate from libraries.
packages/ All your reusable components go here. Encourages modular design.
Root files Workspace management only β€” no code. Keeps things clean.
package.json Declares this folder as a workspace root
pnpm-workspace.yaml Defines the packages/projects to include from anywhere in the folder tree
pnpm-lock.yaml Locks all dependencies across your entire monorepo, ensuring reproducible installs

2.2 Configure Project Folder Structure

Similarly a minimal project structure is created.

This mono repo will have the following two projects SGS and my-osm

Update the folder structure to represent this

D:\WorkArea\Projects\ ... β”œβ”€β”€πŸ“ frontend/ β”‚ β”œβ”€β”€πŸ“ apps/ β”‚ β”‚ β”œβ”€β”€πŸ“ SGS/ ← πŸ“Œ Root of project SGS β”‚ β”‚ β””β”€β”€πŸ“ my-osm/ ← πŸ“Œ Root of project my-osm ...

πŸ“¦Initialize the projects

Open a terminal πŸ’» and navigate to the root folder of each projects and run pnpm init for each projects.

For example, for my-osm project:

πŸ’» cd D:\WorkArea\Projects\React\frontend\apps\my-osm πŸ’» pnpm init

It will create a package.json that looks something like this:

{ "name": "my-osm", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "packageManager": "pnpm@10.7.1" }

As an alternate you can add a minimal package.json manually

{ "name": "my-osm", "version": "1.0.0", }

Repeat it for SGS project.

Similarly, do the same thing on creaing any new project.

Now the folder structure will represent this:

D:\WorkArea\Projects\ β”œβ”€β”€πŸ“ frontend/ β”‚ β”œβ”€β”€πŸ“ apps/ β”‚ β”‚ β”œβ”€β”€πŸ“ SGS/ β”‚ β”‚ | β””β”€β”€πŸ“¦ package.json ← πŸ“Œ Root of project SGS β”‚ β”‚ β””β”€β”€πŸ“ my-osm/ β”‚ β”‚ | β””β”€β”€πŸ“¦ package.json ← πŸ“Œ Root of project mh-osm

2.3 Verify project configurations

Run this in the root folder:

Path: D:\WorkArea\Projects\:

> pnpm install

This will result in one of the following:

Then run:

> pnpm list -r

If it shows your workspace packages (e.g., SGS, my-osm), the setup is correct. The output should be something like this:

react-monorepo β”œβ”€β”€ SGS └── my-osm

Sometime, this may not give the expected result. Try the following instead.

pnpm -r exec -- node -p "'πŸ“¦ Detected: ' + require('./package.json').name"

This will show all the list of all the configured packages, something like:

πŸ“¦ Detected: SGS πŸ“¦ Detected: my-osm

This might also include the package.json at root folder D:\WorkArea\Projects\ and the result could includ this:

πŸ“¦ Detected: projects πŸ‘ˆ From root folder `package.json` πŸ“¦ Detected: SGS πŸ“¦ Detected: my-osm

This confirms PNPM recognizes your workspace correctly.

Just creating the folder will not work. package.config file must exist under each project folder.

✨ TL;DR

Ceate following folder structure under root folder D:\WorkArea\Projects\

D:\WorkArea\Projects\ β”œβ”€β”€πŸ“ node_mdules/ β”œβ”€β”€πŸ“ frontend/ πŸ‘ˆ New folder β”‚ β”œβ”€β”€πŸ“ apps/ πŸ‘ˆ New folder β”‚ β”‚ β”œβ”€β”€πŸ“ SGS/ πŸ‘ˆ New folder: Root of project SGS β”‚ β”‚ β”œβ”€β”€πŸ“ my-osm/ πŸ‘ˆ New folder: Root of project my-osm β”‚ β”œβ”€β”€πŸ“ packages/ πŸ‘ˆ New folder β”œβ”€β”€πŸ“¦ package.json β””β”€β”€πŸ› οΈ+πŸ”’ pnpm-lock.yaml

πŸ“¦Initialize the my-osm project:

> cd D:\WorkArea\Projects\React\frontend\apps\my-osm

> pnpm init

It will create a package.json

Repeat it for SGS project.

Now the folder structure will represent this:

D:\WorkArea\Projects\ β”œβ”€β”€πŸ“ frontend/ β”‚ β”œβ”€β”€πŸ“ apps/ β”‚ β”‚ β”œβ”€β”€πŸ“ SGS/ β”‚ β”‚ | β””β”€β”€πŸ“¦ package.json ← πŸ“Œ Root of project SGS β”‚ β”‚ β””β”€β”€πŸ“ my-osm/ β”‚ β”‚ | β””β”€β”€πŸ“¦ package.json ← πŸ“Œ Root of project mh-osm

Verify project configurations Run this in the root folder: > cd D:\WorkArea\Projects\

> pnpm install

Then run:

` > pnpm list -r`

or

πŸ’» pnpm -r exec -- node -p "'πŸ“¦ Detected: ' + require('./package.json').name"

This will show all the list of all the configured packages, something like:

SGS my-osm

πŸ‘‰ Step 3 Configure the Workspace Manifest

The pnpm-workspace.yaml file tells PNPM which subfolders or sub-projects (React apps, packages, shared utilities, etc.) in your project tree are part of the workspace

Without this file, PNPM won’t treat your subfolders as a monorepo. Dependencies will still be installed per project β€” defeating our goal of sharing and hoisting.

3.1 Create pnpm-workspace.yaml (in root folder)

Path: D:\WorkArea\Projects\pnpm-workspace.yaml

3.2 Configure pnpm-workspace.yaml

Add the following to pnpm-workspace.yaml

packages: - 'frontend/apps/*' - 'frontend/packages/*' - 'shared/*' (This folder is not yet created) - 'backend/*' (This folder is not yet created)

This tells PNPM which subfolders are part of the workspace.

πŸ“ Folder Meaning

Folder Meaning
frontend/apps/* All your application projects like SGS, my-osm
frontend/packages/* All reusable component packages like react-textbox, react-button.
shared/* Common libraries, helpers, etc. (optional for now).

⚠️ Make sure there's no indentation error β€” YAML is sensitive to spaces!

πŸ‘‰ Step 4 Configure my-osm project

4.1 Install Parcel as the Bundler

To install Parcel run the following from inside my-osm folder.

pnpm add -D parcel

This will add the following entry in package.json file.

{ ... "devDependencies": { "parcel": "^2.14.4" } }

Since Parcel is required only during development and bundling, it should be installed as dev dependency using -D option.

βœ… Verify Parcel installation Run the following to verify installation

pnpm list -r parcel

It should be listed as follows under devDependencies

my-osm@1.0.0 D:\deleete\step4\frontend\apps\my-osm devDependencies: πŸ‘ˆ Note this parcel 2.14.4

4.2 Configure project

#####4.2.1 Install React & ReactDOM in my-osm Its time to configure the project, by installing the latest versions of react and react-dom.

Open a terminal πŸ’» and navigate to the root folder of my-osm project

πŸ’» cd D:\WorkArea\Projects\React\frontend\apps\my-osm` πŸ’» pnpm add react react-dom

Verity installation Once installed, the installation can be verified in two ways.

Method 1: Run this command int the same folder:

> pnpm list -r react react-dom

You should see output something like:

my-osm@1.0.0 D:\deleete\step4\frontend\apps\my-osm dependencies: react 19.1.0 react-dom 19.1.0

Method 2:

Check the dependencies section of my-osm/package.json: The file should show the following new entries.

{ ... "dependencies": { "react": "^19.1.0", "react-dom": "^19.1.0" } }

The version may vary depending on the time of installation

#####4.2.2 Add Entry Point to package.json

Open: D:\WorkArea\Projects\frontend\apps\my-osm\package.json and update it with following content.

{ "name": "my-osm", "version": "1.0.0", "scripts": { "dev": "parcel index.html" } }

πŸ’‘ This tells Parcel to start building from index.html, which loads index.jsx.

4.2.3 Create a minimal React file to test setup

index.html

In my-osm, create a new fileindex.html with the following content.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>React Test</title> </head> <body> <div id="root"></div> <script type="module" src="./index.jsx"></script> </body> </html>

main.jsx Create main.jsx with the following content.

import React from "react"; import ReactDOM from "react-dom/client"; const App = () => <h1>Hello React!</h1>; const root = ReactDOM.createRoot(document.getElementById("root")); root.render(<App />);
4.2.4 Run the Dev Server

Now start the dev server by running the following command in my-osm folder.

pnpm run dev

This command will:

You can see the output something like this:

Server running at http://localhost:1234 ✨ Built in 75ms

Verify in Browser

Open http://localhost:1234 in your browser. It should show:

Hello React!

Now we have a working React app powered by Parcel.


πŸ‘‰ Step 5 Install Tailwind CSS for Project with Parcel

5.1 Install Tailwind CSS

Open a terminal πŸ’» and navigate to the root folder of my-osm project

> cd D:\WorkArea\Projects\React\frontend\apps\my-osm

Run the following command

> pnpm add tailwindcss @tailwindcss/postcss

This will add install tailwindcss and @tailwindcss/postcss and update package.json as follows

{ ... "dependencies": { "react": "^19.1.0", "react-dom": "^19.1.0", "tailwindcss": "^4.1.4" πŸ‘ˆ New entry "@tailwindcss/postcss": "^4.1.4", πŸ‘ˆ New entry ... }, ... }

5.2 Configure PostCSS

Create a .postcssrc file in my-osm folder, and enable the @tailwindcss/postcss plugin.

Update the .postcssrc file with the following content

{ "plugins": { "@tailwindcss/postcss": {} } }

5.3 Import Tailwind CSS

Create a index.css file in my-osm folder and add an @import for Tailwind CSS as follows:

@import "tailwindcss";

5.4 Update main.jsx

Update the main.jsx file to reflect implementation of tailwindcss

import React from "react"; import ReactDOM from "react-dom/client"; export const App = () => <div className="p-6 bg-blue-500 text-white text-xl rounded-lg shadow-md"> Tailwind is working! πŸŽ‰ </div>; const root = ReactDOM.createRoot(document.getElementById("root")); root.render(<App />);

5.5 Update index.html

Add the above index.css file to the <head> of index.html file.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <link href="./index.css" type="text/css" rel="stylesheet" /> πŸ‘ˆ New entry <title>Tailwind CSS Test</title> </head> <body> <div id="root"></div> <script type="module" src="./main.jsx"></script> </body> </html>

5.6 Start using Tailwind

Start using tailwind by running the dev server

pnpm run dev

Verify in Browser

Open http://localhost:1234 in your browser. It should show the following styled text (blue background, white text).

Tailwind is working! πŸŽ‰

Now we have a working React app powered by Parcel, intergrated with Tailwind CSS.

>>end of step 5



D:\WorkArea\Projects\ β”œβ”€β”€ frontend/ β”‚ β”œβ”€β”€ apps/ β”‚ β”‚ β”œβ”€β”€ SGS/ β”‚ β”‚ └── my-osm/ β”‚ β”œβ”€β”€ packages/ β”‚ β”‚ β”œβ”€β”€ react-textbox/ β”‚ β”‚ └── react-button/ β”‚ └── configs/ β”‚ β”œβ”€β”€ tailwind.common.config.js β”‚ β”œβ”€β”€ postcss.common.config.js β”‚ └── parcel.common.config.js β”‚ β”œβ”€β”€ backend/ β”‚ β”œβ”€β”€ auth-api/ β”‚ └── billing-service/ β”‚ β”œβ”€β”€ shared/ β”‚ β”œβ”€β”€ logger/ β”‚ β”œβ”€β”€ constants/ β”‚ └── date-utils/ β”‚ β”œβ”€β”€ scripts/ β”‚ └── sync-version.js β”‚ β”œβ”€β”€ .vscode/ β”‚ └── settings.json β”œβ”€β”€ .editorconfig β”œβ”€β”€ .gitignore β”œβ”€β”€ package.json ← πŸ“Œ Root of your workspace β”œβ”€β”€ pnpm-lock.yaml └── pnpm-workspace.yaml ← πŸ“Œ Workspace map

🧠 Why This Structure?

Folder Purpose
apps/ For apps or demo projects. Keeps them separate from libraries.
packages/ All your reusable components go here. Encourages modular design.
configs/ Central spot for Tailwind/PostCSS config reuse (optional).
Root files Workspace management only β€” no code. Keeps things clean.

βœ… Where Should package.json, pnpm-lock.yaml, and pnpm-workspace.yaml Live? These files should always live at the root of your workspace, not inside frontend/ or backend/.

βœ… So: They belong in πŸ“ D:\WorkArea\Projects\

Why?

File Why it lives at the root package.json Declares this folder as a workspace root ("private": true, "workspaces": [...]) pnpm-workspace.yaml Defines the packages/projects to include from anywhere in the folder tree pnpm-lock.yaml Locks all dependencies across your entire monorepo, ensuring reproducible installs

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

πŸ“ Batch File (init-tailwind.bat)

@echo off echo Creating tailwind.config.js... echo module.exports = { content: ["./index.html", "./src/**/*.{js,jsx}"], theme: { extend: {} }, plugins: [], } > tailwind.config.js echo Creating postcss.config.js... echo module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, } > postcss.config.js echo Done!

βœ… Tooling Notes

🧠 VSCode Tips & Extensions (Reminder)

2.1 (removed content)

🧠 Why This Structure:

Folder Purpose
apps/ For apps or demo projects. Keeps them separate from libraries.
packages/ All your reusable components go here. Encourages modular design.

|configs/ |Central spot for Tailwind/PostCSS config reuse (optional).| |Root files| Workspace management only β€” no code. Keeps things clean.| | |package.json Declares this folder as a workspace root | | | pnpm-workspace.yaml Defines the packages/projects to include from anywhere in the folder tree | | |pnpm-lock.yaml Locks all dependencies across your entire monorepo, ensuring reproducible installs |