vite-plugin-pwa: error injecting head tag with Remix vite plugin

Remix has recently stabilized it’s Vite support and will be migrating to it in the future.

I tried to setup vite-plugin-pwa but it seems like there is some problem with Remix and the plugin to be able to inject the proper head tags at the moment (not head tag is injected at the moment)

Repoduction steps

  1. init a new remix project with the vite template with: npx create-remix@latest --template remix-run/remix/templates/vite
  2. install and setup vite-plugin-pwa

workaround

I can manually inject the link tag in my app/root.tsx file and the manifest is now properly injected. I suspect that Remix override vite-plugin-pwa with it’s own head tag handling logic.

// app/root.tsx

  import {
    Links,
    Meta,
    Outlet,
    Scripts,
    ScrollRestoration,
  } from "@remix-run/react";
  import "./styles.css";

  export function Layout(props: { children: React.ReactNode }) {
    return (
      <html lang="en">
        <head>
          <meta charSet="utf-8" />
          <meta name="viewport" content="width=device-width, initial-scale=1" />
          <Meta />
          <Links />
          <link rel="manifest" href="/manifest.webmanifest"></link>
        </head>
        <body>
          {props.children}
          <ScrollRestoration />
          <Scripts />
        </body>
      </html>
    );
  }

  export default function App() {
    return <Outlet />;
  }

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 29 (22 by maintainers)

Most upvoted comments

I Will try to add an example and include remix in the docs…

@xstevenyung FYI https://github.com/vite-pwa/remix, I’m preparing release and docs…

@xstevenyung we need a custom plugin for remix, this weekend I’ll try to create it: @vite-pwa/remix with similar logic and a few options to customize the build.

spa pwa changes can be found here with some configuration changes: https://github.com/userquin/remix-pwa/pull/1