Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor tailwind config path, add tailwind document #11786

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions docusaurus/docs/adding-tailwind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
id: adding-tailwind
title: Adding Tailwind
---

> Note: this feature is available with `react-scripts@5.0.0` and higher.

[Tailwind](https://tailwindcss.com/) is a utility-first CSS framework packed with classes.

## Installation

```sh
npm install -D tailwindcss
```

## Usage

1. You can use tailwind css simply adding `tailwind.config.js` in your root directory.

```javascript
// tailwind.config.js
module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
extend: {},
},
plugins: [],
};
```

2. Import tailwind stylesheet.

```css
/* App.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
```

3. Example

```javascript
// App.js
import './App.css';

function App() {
return (
<div>
<h1 class="text-3xl font-bold underline">Hello world!</h1>
</div>
);
}

export default App;
```

---

- Here is more guide for tailwind css configuration. [A guide to configuring and customizing your Tailwind installation.](https://tailwindcss.com/docs/configuration)

- If you are using under `react-scripts@5.0.0` version, follow this step. [Install Tailwind CSS with Create React App](https://tailwindcss.com/docs/guides/create-react-app)
1 change: 1 addition & 0 deletions docusaurus/website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"adding-a-css-modules-stylesheet",
"adding-a-sass-stylesheet",
"adding-css-reset",
"adding-tailwind",
"post-processing-css",
"adding-images-fonts-and-files",
"loading-graphql-files",
Expand Down
3 changes: 3 additions & 0 deletions packages/react-scripts/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = {
appSrc: resolveApp('src'),
appTsConfig: resolveApp('tsconfig.json'),
appJsConfig: resolveApp('jsconfig.json'),
tailwindConfig: resolveApp('tailwind.config.js'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
proxySetup: resolveApp('src/setupProxy.js'),
Expand All @@ -96,6 +97,7 @@ module.exports = {
appTsConfig: resolveApp('tsconfig.json'),
appJsConfig: resolveApp('jsconfig.json'),
yarnLockFile: resolveApp('yarn.lock'),
tailwindConfig: resolveApp('tailwind.config.js'),
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
proxySetup: resolveApp('src/setupProxy.js'),
appNodeModules: resolveApp('node_modules'),
Expand Down Expand Up @@ -134,6 +136,7 @@ if (
appTsConfig: resolveOwn(`${templatePath}/tsconfig.json`),
appJsConfig: resolveOwn(`${templatePath}/jsconfig.json`),
yarnLockFile: resolveOwn(`${templatePath}/yarn.lock`),
tailwindConfig: resolveOwn(`${templatePath}/tailwind.config.js`),
testsSetup: resolveModule(resolveOwn, `${templatePath}/src/setupTests`),
proxySetup: resolveOwn(`${templatePath}/src/setupProxy.js`),
appNodeModules: resolveOwn('node_modules'),
Expand Down
4 changes: 1 addition & 3 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ const imageInlineSizeLimit = parseInt(
const useTypeScript = fs.existsSync(paths.appTsConfig);

// Check if Tailwind config exists
const useTailwind = fs.existsSync(
path.join(paths.appPath, 'tailwind.config.js')
);
const useTailwind = fs.existsSync(paths.tailwindConfig);

// Get the path to the uncompiled service worker (if it exists).
const swSrc = paths.swSrc;
Expand Down