-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(create-gatsby): Add Tailwind as a styling choice (#37944)
Co-authored-by: LekoArts <lekoarts@gmail.com>
- Loading branch information
1 parent
768581f
commit cbc0b35
Showing
8 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as fs from "fs-extra" | ||
import path from "path" | ||
|
||
export interface IFile { | ||
source: string | ||
targetPath: string | ||
} | ||
|
||
async function writeFile({ source, targetPath }: IFile): Promise<void> { | ||
// Read the stub | ||
const stubData = await fs.readFile(source) | ||
// Write stub to targetPath | ||
await fs.outputFile(targetPath, stubData) | ||
} | ||
|
||
export async function writeFiles( | ||
rootPath: string, | ||
files: Array<IFile> | undefined | ||
): Promise<void> { | ||
if (!files) { | ||
return | ||
} | ||
|
||
// Necessary to grab files from the stub/ dir | ||
const createGatsbyRoot = path.join(__dirname, `..`) | ||
// Creating files in parallel | ||
const results = [] | ||
|
||
for (const file of files) { | ||
const source = path.resolve(createGatsbyRoot, file.source) | ||
const targetPath = path.resolve(rootPath, file.targetPath) | ||
|
||
results.push(writeFile({ source, targetPath })) | ||
} | ||
|
||
await Promise.all(results) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./src/styles/global.css" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/create-gatsby/stubs/tailwindcss/tailwind.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: [ | ||
`./src/pages/**/*.{js,jsx,ts,tsx}`, | ||
`./src/components/**/*.{js,jsx,ts,tsx}`, | ||
], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
} |