forked from vercel/turborepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(example): tailwind improvement and treeshaking (vercel#3557)
Tailwind example improvements: * Enable treeshaking by bundling to esm instead of cjs * Prefix UI classes to avoid app conflicts * Use tsup to bundle css instead of tailwindcss * Write new `Card` component to demo bundle size difference between web / docs
- Loading branch information
Showing
11 changed files
with
181 additions
and
196 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,9 @@ | ||
// If you want to use other PostCSS plugins, see the following: | ||
// https://tailwindcss.com/docs/using-with-preprocessors | ||
|
||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
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,27 @@ | ||
import * as React from "react"; | ||
|
||
export const Card = ({ | ||
title, | ||
cta, | ||
href, | ||
}: { | ||
title: string; | ||
cta: string; | ||
href: string; | ||
}) => { | ||
return ( | ||
<a | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
href={href} | ||
className="ui-group ui-mt-4 ui-rounded-lg ui-border ui-border-transparent ui-overflow-hidden ui-bg-origin-border ui-bg-gradient-to-r ui-from-brandred ui-to-brandblue ui-text-[#6b7280]" | ||
> | ||
<div className="ui-p-4 ui-bg-zinc-900 ui-h-full"> | ||
<p className="ui-inline-block ui-text-xl ui-text-white">{title}</p> | ||
<div className="ui-text-xs ui-mt-4 group-hover:ui-underline"> | ||
{cta} → | ||
</div> | ||
</div> | ||
</a> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,8 @@ | ||
import * as React from "react"; | ||
|
||
// styles | ||
import "./styles.css"; | ||
|
||
// components | ||
export * from "./Button"; | ||
export * from "./Card"; |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
// tailwind config is required for editor support | ||
const sharedConfig = require("tailwind-config/tailwind.config.js"); | ||
|
||
module.exports = require("tailwind-config/tailwind.config.js"); | ||
module.exports = { | ||
// prefix ui lib classes to avoid conflicting with the app | ||
prefix: "ui-", | ||
...sharedConfig, | ||
}; |
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,13 @@ | ||
import { defineConfig, Options } from "tsup"; | ||
|
||
export default defineConfig((options: Options) => ({ | ||
treeshake: true, | ||
splitting: true, | ||
entry: ["src/**/*.tsx"], | ||
format: ["esm"], | ||
dts: true, | ||
minify: true, | ||
clean: true, | ||
external: ["react", "react-dom"], | ||
...options, | ||
})); |
Oops, something went wrong.