sintaxi/harp

Copy file with leading underscore

Nadeeshyama opened this issue · 8 comments

I'm using Harp on Netlify and want to add some redirects. However, Harp doesn't process files starting with an underscore character and Netlify's redirect file name is "_redirects". I know npm scripts can be used to combine a copy command along with harp compile but wondering whether there's a another way to do it within Harp.

Thanks.

I too second this - I want to include a _headers file in the root of public for setting up basic auth... as well as redirects. @Nadeeshyama did you have any luck with this?

@mjsweet @Nadeeshyama I can't replicate the issue. I'm guessing for @Nadeeshyama it's a Netlify issue and for you @mjsweet I'm not sure how you did it to recreate his issue, but I just used _headers.jade and it imported just fine. Perhaps I misunderstand your situation. If you find you are still having the issue, please follow up here or in a new Issue and we can try work it out together.

I too second this - I want to include a _headers file in the root of public for setting up basic auth... as well as redirects. @Nadeeshyama did you have any luck with this?

I ended up using an npm script entry. I run this after harp compile as part of my build.
"postdep": "shx cp -uR config/* www/"

Hi @Nadeeshyama, this is a great solution. @misterhtmlcss basically any file with and underscore prefix won't go into the compiled version of the site, so the _headers file is basically ignored by harp compile.

I too second this - I want to include a _headers file in the root of public for setting up basic auth... as well as redirects. @Nadeeshyama did you have any luck with this?

I ended up using an npm script entry. I run this after harp compile as part of my build.
"postdep": "shx cp -uR config/* www/"

I will use it @Nadeeshyama - thanks for posting the line.

@mjsweet @Nadeeshyama I can't replicate the issue. I'm guessing for @Nadeeshyama it's a Netlify issue and for you @mjsweet I'm not sure how you did it to recreate his issue, but I just used _headers.jade and it imported just fine. Perhaps I misunderstand your situation. If you find you are still having the issue, please follow up here or in a new Issue and we can try work it out together.

In my case its a plain text file (for Netlify redirects) that need to be copied to www folder without being processed. I'm only familiar with Netlify, but I'm guessing other hosting providers could have config files starting with an underscore too.

I too second this - I want to include a _headers file in the root of public for setting up basic auth... as well as redirects. @Nadeeshyama did you have any luck with this?

I ended up using an npm script entry. I run this after harp compile as part of my build.
"postdep": "shx cp -uR config/* www/"

I will use it @Nadeeshyama - thanks for posting the line.

👍

@Nadeeshyama @mjsweet I was reading through Netlify and if that's the site you guys are both working with then I see looking at the docs (relevant link) that you can use a netlify.toml instead of a _redirects file. I think that's the best solution in the context of Netlify.

If there are other tools/platforms you are working with let me know and we can look together to see if they have alternatives as well.