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

Update tailwind style tag generation #2734

Merged
merged 3 commits into from
Jan 29, 2025
Merged

Conversation

wizardlyhel
Copy link
Contributor

@wizardlyhel wizardlyhel commented Jan 29, 2025

WHY are these changes introduced?

Follow up from #2701 - Fix failed to execute 'insertBefore' on 'Node' error during development

When generating a new project with tailwind css, the tailwind style tag is being generated in the wrong place. The expected root file generation is:

export function links() {
  return [
-    {rel: 'stylesheet', href: tailwindCss},
    {
      rel: 'preconnect',
      href: 'https://cdn.shopify.com',
    },
    {
      rel: 'preconnect',
      href: 'https://shop.app',
    },
    {rel: 'icon', type: 'image/svg+xml', href: favicon},
  ];
}

...

export function Layout({children}: {children?: React.ReactNode}) {
  const nonce = useNonce();
  const data = useRouteLoaderData<RootLoader>('root');

  return (
    <html lang="en">
      <head>
        <meta charSet="utf-8" />
        <meta name="viewport" content="width=device-width,initial-scale=1" />
+       <link rel="stylesheet" href={tailwindCss}></link>
        <link rel="stylesheet" href={resetStyles}></link>
        <link rel="stylesheet" href={appStyles}></link>

WHAT is this pull request doing?

  • Updating the AST replacer for injecting tailwind node elements
  • Updating the test for tailwind project generation

HOW to test your changes?

In the mono repo, run npx shopify hydrogen init and create a project with tailwind css option selected. Check the root.tsx to ensure tailwind css is generated correctly

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Contributor

shopify bot commented Jan 29, 2025

Oxygen deployed a preview of your hl-tailwind-style-tag branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment January 29, 2025 9:55 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment January 29, 2025 9:55 PM
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment January 29, 2025 9:55 PM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment January 29, 2025 9:55 PM
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment January 29, 2025 9:55 PM

Learn more about Hydrogen's GitHub integration.

@wizardlyhel wizardlyhel merged commit bf39d28 into main Jan 29, 2025
12 checks passed
@wizardlyhel wizardlyhel deleted the hl-tailwind-style-tag branch January 29, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants