[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posthtml-cli not working properly #326

Closed
nauvalazhar opened this issue Sep 28, 2020 · 6 comments
Closed

posthtml-cli not working properly #326

nauvalazhar opened this issue Sep 28, 2020 · 6 comments
Labels

Comments

@nauvalazhar
Copy link
nauvalazhar commented Sep 28, 2020

Hi,

I use posthtml-cli, when I build like this:

posthtml -c posthtml.json

The command doesn't output any output and doesn't compile anything.

Here is the configuration:

{
  "root": "./src",
  "input": "./src/*.html",
  "output": "dist",
  "plugins": {
    "posthtml-include": {
      "root": "./src/partials"
    },
    "posthtml-extend": {
      "root": "./src/layouts"
    }
  }
}

And here is my package.json file:

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "devDependencies": {
    "@babel/cli": "^7.11.6",
    "@babel/core": "^7.11.6",
    "@babel/polyfill": "^7.11.5",
    "@babel/preset-env": "^7.11.5",
    "cpx": "^1.5.0",
    "imagemin-cli": "^6.0.0",
    "lite-server": "^2.5.4",
    "nodemon": "^2.0.4",
    "npm-run-all": "^4.1.5",
    "posthtml-cli": "^0.7.6",
    "posthtml-extend": "^0.5.0",
    "posthtml-include": "^1.4.3",
    "cross-env": "^7.0.2"
  },
  "dependencies": {
    "tailwindcss": "^1.8.7",
    "@tailwindcss/custom-forms": "^0.2.1"
  },
  "scripts": {
    "html": "posthtml -c posthtml.json",
    "watch:html": "nodemon -w src/**/*.html -e html -x \"posthtml -c posthtml.json\"",
    "tailwind": "tailwindcss build src/css/style.css -o dist/css/style.css",
    "watch:tailwind": "nodemon -w src/css -w tailwind.config.js -e css,js -x \"tailwindcss build src/css/style.css -o dist/css/style.css\"",
    "js": "babel src/js -d dist/js",
    "watch:js": "babel src/js -d dist/js -w",
    "img": "imagemin src/images/* -o dist/images",
    "watch:img": "cpx \"src/images/**/*.*\" dist/images --watch",
    "server": "lite-server -c server.json",
    "watch": "npm-run-all --parallel watch:* server",
    "dev": "npm-run-all tailwind html js img",
    "prod": "cross-env NODE_ENV=production npm-run-all html tailwind js img"
  }
}

And here's my folder structure:

- src/index.html
- src/layouts/layout.html
- posthtml.json
- package.json

Thank you for making this awesome tool!

@Scrum
Copy link
Member
Scrum commented Sep 28, 2020

@nauvalazhar Hi, I created an example in which everything works, clarify what exactly does not work for you

@nauvalazhar
Copy link
Author

But, mine still not working. Can I have a full example of yours?
image

@Scrum
Copy link
Member
Scrum commented Sep 29, 2020

@nauvalazhar You can freely clone this example https://github.com/posthtml-issues/posthtml-cli-issue-326, make changes to it that reproduce your error. Feel free

@turusuke
Copy link
Contributor
turusuke commented Oct 11, 2020

@Scrum
When the root option is enabled, it does not appear to be running. 😢
I think it's because of this change.

return `${ignoreSymbol}${normalizePath(path.join(path.resolve(root), file))}`;

I have verified the following.

Input folder tree

inputDir
└── parent
    ├── about
    │   └── index.html
    ├── fuga
    │   ├── index.html
    │   └── wao
    │       └── index.html
    ├── index.html
    └── other.html

Execute the following command in the current state.

node lib/cli.js inputDir/**/*.html -o outputDir --root inputDir -a

As a result, nothing is output.
So I tried to make the following change.

--${ignoreSymbol}${normalizePath(path.join(path.resolve(root), file))}
++${ignoreSymbol}${normalizePath(file)}

Do the same with posthtml-cli

node lib/cli.js inputDir/**/*.html -o outputDir --root inputDir -a

I got the correct output.

Output folder tree

outputDir
└── parent
    ├── about
    │   └── index.html
    ├── fuga
    │   ├── index.html
    │   └── wao
    │       └── index.html
    ├── index.html
    └── other.html

I tried to make a pull request, but the test failed, so I couldn't push it. 😅
So I'll share with you what I think is the cause of the problem ahead of time.

@Scrum
Copy link
Member
Scrum commented Oct 12, 2020

@nauvalazhar @turusuke Thank you, I still managed to find the problem thanks to you.

@Scrum
Copy link
Member
Scrum commented Oct 12, 2020

Also, pay attention to the correctness of the input files, they should not contain the folder specified in root

node lib/cli.js **/*.html -o outputDir --root inputDir -a

@Scrum Scrum closed this as completed in 45a42ee Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants