-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
bug(windows): paths #17
Comments
@Kristinita resolve in version 0.1.6 |
Status: CONFIRMED ✔️ I upgraded posthtml-img-autosize to the version 0.1.6 → in Windows I got the same behavior as for Linux; see AppVeyor build. Thanks. |
@Scrum, excuse me, I said “confirmed” too early Status: Another problem ❗ 1. Summaryposthtml-img-autosize 0.1.6 works incorrectly, if HTML files and images are in folders and/or subfolders. 2. DetailsAs I wrote in the section 7 of original issue, “I don’t understand why posthtml-img-autosize has a HTML already use relative paths. For example, we have a line in our HTML: <img alt="Nelia leaves" src="NeliaLeaves.jpg"> And a project where HTML files are located in various folders and subfolders. 3. Behavior 13.1. ExpectedIf HTML file is elif correct path for image is else and so on. 3.2. CurrentIn all three cases above posthtml-img-autosize tries to find the file 4. MCVEYou can see this configuration in the
5. Behavior 2Correct image path is 5.1. CLI
5.2. Grunt
Thanks. |
The build process itself has a root and all running build processes will rely on this root, accordingly plugins need to specify paths relative to the root of the build process module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-posthtml'
grunt.initConfig
posthtml:
options:
use: [
require('posthtml-img-autosize')(
root: 'KiraFolder',
processEmptySize: true
)
]
target:
files: [
expand: true
cwd: '.'
src: 'KiraFolder/*.html'
dest: '.'
ext: '.output.html'
]
|
Status: Not fixed 😿 1. Details@Scrum, I don’t understand, how it can solve paths problem for real projects with multiple folders and subfolders. And I still think that the If it doesn’t, please show the correct 2. MCVESee this configuration in KiraPosthtmlImgAutosizeMultipleFiles branch of my repository for demonstrations and debugging.
Parts of the files:
Paths in the Thanks. |
You can not specify the root directory, but then you need to specify the full path to the resource location. Because your paths are relative to the root directory <img alt="Nelia leaves" src="KiraFolder/NeliaLeaves.jpg"> |
Status: Not fixed 😿
@Scrum, but browsers will not find the correct path to the image in this case. The image will not be displayed in browsers. Thanks. |
It seems to me that you have a rather confusing connection between templates and static resources. I can suggest you structure your ecosystem to something like this
Try to keep all static resources in one place |
Status: Still not fixed 😿 1. MCVEType: Counterargument 💬 The structure of files and folders in the folder
Parts of files:
<img alt="Nelia leaves" src="assets/NeliaLeaves.jpg">
<img alt="Nelia leaves" src="../assets/NeliaLeaves.jpg">
<img alt="Nelia leaves" src="../../assets/NeliaLeaves.jpg"> posthtml-img-autosize will not work in this case. 2. QuestionsType: Questions ❓
Thanks. |
At the moment, relative paths are supported, but it should be borne in mind that they are resolved relative to the running process + root options and not relative to the html file |
Type: Questions ❓
Yes, I understand the behavior at the moment, but my question is about something else. I’ll try to ask questions in other words:
Thanks. |
Yes, you can create a task feature where the root directory will be the context entry file. |
Type: Question ❓
Could you give an example of what you said (for example, for this MCVE)? Thanks. |
posthtml:
options:
use: [
require('posthtml-img-autosize')(
root: 'byEntry'
)
] or new property posthtml:
options:
use: [
require('posthtml-img-autosize')(
ctx: 'byEntry'
)
] |
Type: Reply 💬 It has no effect: commit changes — Travis build failed. Thanks. |
This is an example of a feature that needs to be implemented. :) |
Type: Question ❓ Are there any chances that this feature will be implemented? Thanks. |
There are always chances |
@Scrum, OK, we are waiting for this feature to be implemented. Thanks. |
This issue is still relevant for August, 2022. I still can’t find any alternative that automatically adds Thanks. |
@Kristinita Hello, please create a new task, it is very difficult to understand the essence of the problem. a lot of comments. Thank you. |
1. Summary
posthtml-img-autosize doesn’t work for Windows.
I get errors as:
2. Reproducibility
I reproduce the problem for posthtml-cli and grunt-posthtml both on Windows.
On Linux I don’t have this problem.
I successfully use some another posthtml plugins (example), so I think that possibly that the problem is specific for the posthtml-img-autosize plugin.
3. Configuration
Operating system:
posthtml:
posthtml-img-autosize 0.1.5
4. MCVE
You can see the configuration in the
KiraPosthtmlAsync
branch of my demo/debugging repository.KiraPosthtml.html
:Gruntfile.coffee
:The part of
.travis.yml
— Ubuntu build:The part of
appveyor.yml
— Windows build:5. Behavior
5.1. Ubuntu — expected
Travis build:
posthtml-img-autosize successfully add width and height for CLI and Grunt commands.
5.2. Windows — bug
AppVeyor build:
Path problem for CLI and Grunt both.
6. Not helped
I tried:
6.1. CLI
Command-line arguments like:
-r '.'
--posthtml-img-autosize.root '\.'
6.2. Grunt
Options like:
root: '\.'
root: process.cwd()
7. root option
I don’t understand why posthtml-img-autosize has a
root
option at all. PostHTML works with HTML directly. In HTML, relative links to images look like:src="NeliaLeaves.jpg"
src="..\..\path\to\NeliaLeaves.jpg"
Is these cases a
root
option not really needed.Is it needed in any other cases?
Thanks.
The text was updated successfully, but these errors were encountered: