Skip to content

Commit 5614c87

Browse files
authoredDec 14, 2021
Add support for Tailwind (#11717)
1 parent 657739f commit 5614c87

File tree

4 files changed

+657
-343
lines changed

4 files changed

+657
-343
lines changed
 

‎package-lock.json

+620-323
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/react-scripts/config/webpack.config.js

+36-16
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ const imageInlineSizeLimit = parseInt(
6868
// Check if TypeScript is setup
6969
const useTypeScript = fs.existsSync(paths.appTsConfig);
7070

71+
// Check if Tailwind config exists
72+
const useTailwind = fs.existsSync(
73+
path.join(paths.appPath, 'tailwind.config.js')
74+
);
75+
7176
// Get the path to the uncompiled service worker (if it exists).
7277
const swSrc = paths.swSrc;
7378

@@ -135,22 +140,37 @@ module.exports = function (webpackEnv) {
135140
// Necessary for external CSS imports to work
136141
// https://github.com/facebook/create-react-app/issues/2677
137142
ident: 'postcss',
138-
plugins: [
139-
'postcss-flexbugs-fixes',
140-
[
141-
'postcss-preset-env',
142-
{
143-
autoprefixer: {
144-
flexbox: 'no-2009',
145-
},
146-
stage: 3,
147-
},
148-
],
149-
// Adds PostCSS Normalize as the reset css with default options,
150-
// so that it honors browserslist config in package.json
151-
// which in turn let's users customize the target behavior as per their needs.
152-
'postcss-normalize',
153-
],
143+
config: false,
144+
plugins: !useTailwind
145+
? [
146+
'postcss-flexbugs-fixes',
147+
[
148+
'postcss-preset-env',
149+
{
150+
autoprefixer: {
151+
flexbox: 'no-2009',
152+
},
153+
stage: 3,
154+
},
155+
],
156+
// Adds PostCSS Normalize as the reset css with default options,
157+
// so that it honors browserslist config in package.json
158+
// which in turn let's users customize the target behavior as per their needs.
159+
'postcss-normalize',
160+
]
161+
: [
162+
'tailwindcss',
163+
'postcss-flexbugs-fixes',
164+
[
165+
'postcss-preset-env',
166+
{
167+
autoprefixer: {
168+
flexbox: 'no-2009',
169+
},
170+
stage: 3,
171+
},
172+
],
173+
],
154174
},
155175
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
156176
},

‎packages/react-scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"semver": "^7.3.5",
7070
"source-map-loader": "^3.0.0",
7171
"style-loader": "^3.3.1",
72+
"tailwindcss": "^3.0.2",
7273
"terser-webpack-plugin": "^5.2.5",
7374
"webpack": "^5.64.4",
7475
"webpack-dev-server": "^4.6.0",

‎tasks/cra.js

-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ const scriptsFileName = cp
104104
.toString()
105105
.trim();
106106
const scriptsPath = path.join(packagesDir, 'react-scripts', scriptsFileName);
107-
108-
// Now that we have packed them, call the global CLI.
109-
cp.execSync('npm cache clean');
110-
111107
const args = process.argv.slice(2);
112108

113109
// Now run the CRA command

0 commit comments

Comments
 (0)
Please sign in to comment.