11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.12k stars 494 forks source link

New passthrough copy during serve / symlinks #2485

Closed TigersWay closed 2 years ago

TigersWay commented 2 years ago

Describe the bug While the use of the recursive-copy package allow to use symlinks, it seems it does not not work in dev mode (--serve)

eleventyConfig.addPassthroughCopy("img", {
    expand: true, // expand symbolic links
  });

To Reproduce Steps to reproduce the behavior:

...
 eleventyConfig.addPassthroughCopy({'node_modules/@fontsource/allura/files': 'css/files'}, {expand: true});
...

Will not work under pnpm & dev mode But I can easily guess i could find other "use case"

Expected behavior Same behavior for build mode or dev mode

Environment: Only important element, I use pnpm not npm

Following: https://github.com/11ty/eleventy/issues/2456

pdehaan commented 2 years ago

I've never used pnpm, but here's what I'm seeing (macOS 12.4, Node 16.15.x ft. npm 8.11.0 and pnpm 7.5.0):

npm version
{
  '11ty-2485': '1.0.0',
  npm: '8.11.0',
  node: '16.15.1',
  ...
}

npm install -g pnpm
pnpm --version # 7.5.0

# install dependencies
pnpm install

pnpm serve

> 11ty-2485@1.0.0 serve /private/tmp/11ty-2485
> eleventy --serve

[11ty] Writing www/index.html from ./src/index.njk
[11ty] Copied 8 files / Wrote 1 file in 0.10 seconds (v1.0.1)
[11ty] Watching…
[Browsersync] Access URLs:
 -----------------------------------
    Local: http://localhost:8082
 External: http://192.168.7.121:8082
 -----------------------------------
[Browsersync] Serving files from: www

So it seems to be copying 8 files (macOS 12.4).

Here's my .eleventy.js file:

// .eleventy.js
module.exports = function (eleventyConfig) {
  eleventyConfig.addPassthroughCopy({'node_modules/@fontsource/allura/files': 'css/files'}, {expand: true});

  return {
    dir: {
      input: "src",
      output: "www",
    }
  };
};

… and my package.json:

{
  "name": "11ty-2485",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "vercheck": "npm version",
    "build": "eleventy",
    "serve": "eleventy --serve",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "Peter deHaan <peter@deseloper.com>",
  "license": "MPL-2.0",
  "devDependencies": {
    "@11ty/eleventy": "^1.0.1",
    "@fontsource/allura": "^4.5.9"
  },
  "description": ""
}

And the contents of my output folder:

tree www

www/
├── css/
│   └── files/
│       ├── allura-all-400-normal.woff
│       ├── allura-latin-400-normal.woff
│       ├── allura-latin-400-normal.woff2
│       ├── allura-latin-ext-400-normal.woff
│       ├── allura-latin-ext-400-normal.woff2
│       ├── allura-vietnamese-400-normal.woff
│       ├── allura-vietnamese-400-normal.woff2
│       └── file-list.json
└── index.html

2 directories, 9 files
pdehaan commented 2 years ago

Ah, although, i think the behavior might be subtlety different in v2.0.0-canary.12:

pnpm build

> 11ty-2485@1.0.0 build /private/tmp/11ty-2485
> eleventy

[11ty] Writing www/index.html from ./src/index.njk
[11ty] Copied 8 files / Wrote 1 file in 0.04 seconds (v2.0.0-canary.12)

versus:

 pnpm serve

> 11ty-2485@1.0.0 serve /private/tmp/11ty-2485
> eleventy --serve

[11ty] Writing www/index.html from ./src/index.njk
[11ty] Wrote 1 file in 0.17 seconds (v2.0.0-canary.12)
[11ty] Watching…
[11ty] Server at http://localhost:8082/
TigersWay commented 2 years ago

Sorry for your time @pdehaan ! I have no idea how I manage it yesterday despite all the tests and tries I did, but it's working great today 😊 pnpm is still great! eleventy 2.0 is the best!