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

addPassthroughCopy with symLinks not working #530

Closed
johanlef opened this issue May 16, 2019 · 11 comments
Closed

addPassthroughCopy with symLinks not working #530

johanlef opened this issue May 16, 2019 · 11 comments
Labels
enhancement feature: 🗄 passthrough copy Related to the passthrough file copy feature

Comments

@johanlef
Copy link

I have a submodule which contains templates, css and assets shared by multiple 11ty projects. I symlink the assets I need from the submodule into the assets directory in the root. This assets folder should be copied to _site with addPassthroughCopy('assets') in my .eleventy.js file. Note: I do not use an .eleventyignore file and the sass from the submodule is processed without issues.

Unfortunately, only the files in assets which are not symlinks are copied to the _site directory. How can I tell eleventy to also passthrough my symlinked directories?

assets:
  fonts # symlink to /common/fonts
  logos # symlink to /common/logos
  scripts # normal directory
_site:
  assets:
    scripts # fonts, logos dirs are missing after build
common:
  fonts
  logos
  sass
...

I use eleventy v0.7.1

@zachleat
Copy link
Member

Ah interesting. Eleventy uses recursive-copy for passthrough copy and it does not include symlinks by default.

https://www.npmjs.com/package/recursive-copy#usage

This will require exposing an option to enable this (or maybe configure all of the recursive copy options, not sure).

@zachleat zachleat added enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. labels May 29, 2019
@zachleat
Copy link
Member

This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open.

View the enhancement backlog here. Don’t forget to upvote the top comment with 👍!

@ckot
Copy link

ckot commented May 18, 2020

this would be a nice feature. is there any sort of hack/workaround I could use in the meantime?

@milahu
Copy link
Contributor

milahu commented Mar 12, 2021

still an issue. i use pnpm to manage node_modules, so for example
node_modules/@fontsource/noto-sans is a symlink to
node_modules/.pnpm/@fontsource/noto-sans@4.2.2/node_modules/@fontsource/noto-sans
and running eleventyConfig.addPassthroughCopy("node_modules/@fontsource/noto-sans") will copy zero files

@raxod502
Copy link

raxod502 commented Dec 4, 2021

An easy workaround, add this to .eleventy.js to cause symlinks to be resolved when copying static files:

const TemplatePassthrough = require("@11ty/eleventy/src/TemplatePassthrough");
const origCopy = TemplatePassthrough.prototype.copy;
TemplatePassthrough.prototype.copy = function (src, dest, copyOptions) {
  return origCopy.bind(this)(src, dest, { ...copyOptions, expand: true });
};

@tremby
Copy link

tremby commented Dec 6, 2021

That looks very susceptible to code rot.

@raxod502
Copy link

raxod502 commented Dec 6, 2021

I'm very open to a better solution, please let me know if you have one!

@milahu
Copy link
Contributor

milahu commented Dec 6, 2021

see #1686

@raxod502
Copy link

raxod502 commented Dec 6, 2021

Ah, well, naturally, but until that gets reviewed and merged, I think we're stuck with workarounds like the one I posted.

@milahu
Copy link
Contributor

milahu commented Dec 7, 2021

until that gets reviewed and merged, I think we're stuck

to solve this hostage situation, someone invented patch-package
which also is unmaintained (oh the irony) but it works

sample use in my alchi-book/patches

@zachleat zachleat added feature: 🗄 passthrough copy Related to the passthrough file copy feature and removed needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. labels Jun 24, 2022
@zachleat zachleat added this to the Eleventy 2.0.0 milestone Jun 24, 2022
@zachleat
Copy link
Member

PR is merged, will ship with 2.0.0-canary.12

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature: 🗄 passthrough copy Related to the passthrough file copy feature
Projects
None yet
Development

No branches or pull requests

6 participants