0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

shopifyアプリ開発remixをサブディレクトリにインストール時の不具合

Posted at

概要

以前は Laravel+React や Rails+React のテンプレートがありましたが、長らくメンテナンスされていません。現在は Shopify が Remix を買収した関係で、公式も Remix を推奨する流れになっている気がします。
そこでRemixを使いましたが...
サブディレクトリにインストールした時にエラーがあり苦戦したのでメモとして残します。

本題

本来であれば「vite.config.js」に基準となるパスをサブディレクトリに記述にするように設定すれば、表示されるはずだが、manifestファイルというファイルをRemixが参照する際にこの基準パスを参照せず、トップディレクトリを参照してしまう不具合が存在するため、404になりエラーとなりページを表示できないらしい
↓issues参照

v3_lazyRouteDiscoveryをfalseに設定することで解決する。

vite.config.js
export default defineConfig({
  base: "/test/",
  server: {
    allowedHosts: [host],
    cors: {
      preflightContinue: true,
    },
    port: Number(process.env.PORT || 3000),
    hmr: hmrConfig,
    fs: {
      // See https://vitejs.dev/config/server-options.html#server-fs-allow for more information
      allow: ["app", "node_modules"],
    },
  },
  plugins: [
    remix({
      basename: "/test/",
      ignoredRouteFiles: ["**/.*"],
      future: {
        v3_fetcherPersist: true,
        v3_relativeSplatPath: true,
        v3_throwAbortReason: true,
        v3_lazyRouteDiscovery: true,
        v3_singleFetch: false,
        v3_routeConfig: true,
      },
    }),
    tsconfigPaths(),
  ],
});

※ react-router7では修正されるらしい

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?