addPassthroughCopy can't copy same source folder into several target directories #4038
Replies: 5 comments
-
|
Interesting. It looks like I wonder if you'd have to copy the assets yourself using a 3rd party lib like copy, or cp, or fs-extra. Lines 299 to 316 in 0d18f4d Line 44 in 0d18f4d |
Beta Was this translation helpful? Give feedback.
-
|
Not the prettiest solution, but I liked fs-extra's API the best: const path = require("path");
const fs = require("fs-extra");
module.exports = eleventyConfig => {
/*
// The src/assets files are only copied to the "de/" (last) folder.
eleventyConfig.addPassthroughCopy({ "src/assets": "en" });
eleventyConfig.addPassthroughCopy({ "src/assets": "fr" });
eleventyConfig.addPassthroughCopy({ "src/assets": "de" });
*/
const dir = {
input: "src",
output: "www"
};
const locales = ["en", "fr", "de"];
for (const locale of locales) {
try {
fs.copySync(
// src: "./src/assets/"
path.join(dir.input, "assets"),
// dest: "./www/{{ locale }}/"
path.join(dir.output, locale)
);
} catch (err) {
console.error(err.message);
process.exitCode = 1;
}
}
return {
dir
};
};INPUT$ tree src
src/
├── _data/
├── _includes/
├── assets/
│ ├── site.css
│ └── site.js
└── index.njk
3 directories, 3 filesOUTPUT$ tree www
www/
├── de/
│ ├── site.css
│ └── site.js
├── en/
│ ├── site.css
│ └── site.js
├── fr/
│ ├── site.css
│ └── site.js
└── index.html
3 directories, 7 files |
Beta Was this translation helpful? Give feedback.
-
|
I’d imagine that syntax would probably be something like: eleventyConfig.addPassthroughCopy({ "src/assets": ["en", "de", "fr"] }); |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
This seems to fail with the following message: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to create multi-language webpage.
I need to copy
/assetsinto every language folder:eleventy.js
Project structure:
But
/assetscopied only into/frlanguage.Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions