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

Don’t require passthroughCopy for vite assets #2

Open
zachleat opened this issue Mar 18, 2022 · 3 comments
Open

Don’t require passthroughCopy for vite assets #2

zachleat opened this issue Mar 18, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@zachleat
Copy link
Member

Automatically add a bunch-o-static asset extensions to passthrough copy so that folks don’t have to do it manually. Feedback from https://twitter.com/the_ross_man/status/1504888464076120074

@zachleat zachleat added the enhancement New feature or request label Mar 18, 2022
@mattrossman
Copy link

I noticed that the Vite postprocessing step already discards unused files from the 11ty build. A (maybe silly) idea to consider is having this plugin copy the whole input directory (excluding files that 11ty already ignores) and let Vite figure out what to do with those resources.

For instance:

// .eleventy.js
const EleventyVitePlugin = require("@11ty/eleventy-plugin-vite")

module.exports = function (eleventyConfig) {
  eleventyConfig.addPassthroughCopy("src")
  eleventyConfig.addPlugin(EleventyVitePlugin)
  return {
    dir: {
      input: "src",
    },
  }
}

Given this config, things behave more like I'd expect from Vite. I can have an HTML template that references co-located assets for Vite to process, and files in src/public are automatically treated as static assets by Vite.

I imagine this plugin could do something like this internally, albeit with consideration for excluding eleventyConfig.ignores and stuff like _includes so that it doesn't try to copy over node_modules when using the default input directory.

@zachleat
Copy link
Member Author

zachleat commented Jul 14, 2022

Just a small note that this behavior has likely changed with https://www.11ty.dev/docs/copy/#passthrough-during-serve

Relevant: #9

@shoogstoel
Copy link

Is this still an open issue? I am currently struggling with the basis set-up of my project, because I don't want to add pass trough copies for all the assets I wanna pass to Vite. What's the best practice here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants