posthtml-include: Relative imports not working

Still not works.

posthtml-include@1.2.0
└── src
    ├── assets
    │   └── styles
    │       ├── main.scss
    │       └── shared
    │           └── _variables.scss
    ├── components
    │   ├── button
    │   │   └── button.html
    │   └── footer
    │       └── footer.html
    ├── layout
    │   ├── mainLayout.html
    │   └── main.scss
    └── pages
        ├── index.html
        └── landing.html

pages/landing.html

<include src="../layout/mainLayout.html"></include>

ERROR

🚨  /Projects/src/pages/landing.html: ENOENT: no such file or directory, open '/Projects/layout/mainLayout.html'

.posthtmlrc.js

const path = require("path");

module.exports = {
    plugins: {
        "posthtml-extend": {
            root: path.resolve(__dirname, "src")
        },
        "posthtml-include": {
            root: path.resolve(__dirname, "src")
        },
        "posthtml-modules": {
            root: path.resolve(__dirname, "src")
        },
        "posthtml-expressions": {
            locals: {}
        }
    }
};

Demo reppo: https://github.com/FDiskas/trink _Originally posted by @FDiskas in https://github.com/posthtml/posthtml-include/issues/1#issuecomment-498255242_

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 26 (11 by maintainers)

Most upvoted comments

@jeremysawesome Years later it seems more logical. After re-reading the comments above, I want to apologize @FDiskas for abrupt impudence and lack of involvement.

Now this seems trivial as a solution in the form of a separate option. If you already have a PR, I will be glad to accept it, otherwise please be patient)

you do not understand how the search for the included files goes, see above the results that you will receive and understand your mistakes