LoginSignup
0
0

More than 5 years have passed since last update.

express4 + pug2のbasedir設定

Posted at

問題

  • include ../../../public/img/hoge.png のような相対パス参照がかっこ悪いので解決したい

解決

  • app.js
    let app = express(); // この定義は大体書かれているけど、 appが何者なのかわからなくなるので明示
    app.locals.basedir = path.join(__dirname, 'public');
  • pug
    inclide /img/hoge.png

まとめ

  • IDEが解釈しきれずにエラーにしてくるので、ディレクトリ構成に問題ありと解釈し、相対パスの解決はできるが不採用にした
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