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
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\
As per the planned folder structure, the root of the workspace is:
D:\WorkArea\Projects\
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.
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.configis only for managing the workspace β not an app
π§ Why This Step:
private: true field is required for workspace roots to avoid accidental publishingβ 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
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:
pnpm-lock.yaml at the rootnode_modules shared folder to store all the node modules to be used for all the projects.This detects all
package.jsonfiles 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
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
Before configuring the workspace, a minimal workspace structure is created.
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 |
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
Run this in the root folder:
Path: D:\WorkArea\Projects\:
> pnpm install
This will result in one of the following:
D:\WorkArea\Projects\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.configfile must exist under each project folder.
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
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.
pnpm-workspace.yaml (in root folder)Path: D:\WorkArea\Projects\pnpm-workspace.yaml
pnpm-workspace.yamlAdd 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!
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.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.
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 />);
Now start the dev server by running the following command in my-osm folder.
pnpm run dev
This command will:
http://localhost:1234/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.
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
...
},
...
}
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": {}
}
}
Create a index.css file in my-osm folder and add an @import for Tailwind CSS as follows:
@import "tailwindcss";
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 />);
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>
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.
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
| 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
@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!
tailwindcss init -p@tailwindcss/cli was added to restore expected behaviorπ§ 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 |