Relative links still not functioning correctly
Closed this issue · 7 comments
I know this issue was raised/fixed a month ago but it is definitely still broken in the latest release. Given the following:
src: src/emails/test.html
dest: build/emails/test.html
stylesheet: build/vendor/ink.css
The output is:
../../vendor/ink.css
...which is one directory too far back.
Version 0.4.1 is the last version that works correctly.
@corlletelab did the latest version fix your issue? Trying to figure out why this is persisting.
I am still seeing this problem as well. The output is ../../app/app.js
, which is one directory too far back. No matter how I configure, the directory depth is one level too deep.
Had this issue, had to revert back to 0.4.1 as a workaround. Hoping this gets fixed soon....
I was able to get it work.
Broken version:
htmlbuild: {
dist: {
src: 'index.template.html',
dest: 'index.html'
}
}
Working version:
htmlbuild: {
dist: {
src: 'html_templates/index.html',
dest: '.'
}
}
Basically, keep the template and the output in different directories, and it seems to do exactly what I want.
I'm also having this issue. My script files are referenced as
<script type="text/javascript" src="../../public/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../public/js/sideBar.js"></script>
<script type="text/javascript" src="../public/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../public/js/sideBar.js"></script>
What seems to be the issue in my script and likely the situation brought up by @timhettler comes from how the path module interprets strings as relative paths. For instance,
path.relative(/Users/Labs/views/landing.ejs, /Users/Labs/public/js/bootstrap.min.js);
returns
../../public/js/bootstrap.min.js
while
path.relative(/Users/Labs/views/, /Users/Labs/public/js/bootstrap.min.js);
returns
../public/js/bootstrap.min.js
which is the desired output in this situation. The issue is that the path.relative requires absolute paths, and also (seems) treats the destination path as a directory, that is landing.ejs is thought of as a folder (https://nodejs.org/api/path.html#path_path_relative_from_to). So as of now, the destination needs to be a directory.
Hello,
Sorry for my late answer.
@rjbergerud, @timhettler Thanks for your feedback.
The issue was when providing a file path as dest
path.
It is now fixed in release 0.5.2 which is published to NPM.
Thanks everybody.