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?

AdonisJSでの静的ファイルの扱い方

Last updated at Posted at 2025-11-24

前の記事>AdonisJS入門

動作確認していたらfaviconがないというエラーがずっと出ていて気になったのとないと根本的に困るので配置方法を調べてみた

静的ファイルに関する定義はproject_dir/adonisrc.tsに記載されているようで以下の部分
なのでデフォルトの状態から特に変更する必要はなく以下のディレクトリを用意すればそのまま利用できる

  metaFiles: [
    {
      pattern: 'resources/views/**/*.edge',
      reloadServer: false,
    },
    {
      pattern: 'public/**',
      reloadServer: false,
    },
  ],

つまりproject_dir/publicというディレクトリを作ればその直下がnode ace serve --hmrの起動時に
webルート/に割り当てられる

試しにproject_dir/public/icons/favicon.icoにfaviconファイルを配置して

webの場合
project_dir/resources/views/pages/home.edge
inertiaの場合
project_dir/resources/views/inertia_layout.edge
に以下を追記すれば正しくfaviconが読み込まれた

<link rel="shortcut icon" href="/icons/favicon.ico">

image.png

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?