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

Load vite.config.js for configuration #29

Open
jakewhiteley opened this issue Mar 6, 2023 · 1 comment
Open

Load vite.config.js for configuration #29

jakewhiteley opened this issue Mar 6, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@jakewhiteley
Copy link

I'm not sure of the technical issues behind it, but it seems that if there were a way to grab and load up the vite server using the defineConfig export from a vite.config.js (if present) then it would get around issues such as #24 .

As it stands I personally had to abandon using this plugin as my plugin requirement and general Vite setup is quite complicated.

I ended up just running the Vite/11ty commands sequentially in my package.json (which works kinda but causes race condition issues).

@KiwiKilian
Copy link
Contributor

KiwiKilian commented Jul 2, 2024

With the new upcoming version (already available in alpha) you can use ESM and it's quite easy to load plugins within the .eleventy.js. What other requirements do you have, which would make using vite.config.js easier?

This plugins needs to overwrite some vite options to properly work (e.g. define the input files to your emitted HTML pages, set mode to MPA). So from my point of view, reading a vite.config.js would only help with types and interchangeability. But the current setup shouldn't prevent any functionality which would be enabled by loading an external config.

If you like you can already delcare your vite.config.js as you normally would:

import { defineConfig } from 'vite';

export default defineConfig({
// ...
});

And import this into your .eleventy.js:

import viteConfig from './vite.config.js';

/** @param { import('@11ty/eleventy/src/UserConfig') } eleventyConfig */
export default function (eleventyConfig) {
  eleventyConfig.addPlugin(EleventyVitePlugin, {
    viteOptions: viteConfig,
  });
}

@KiwiKilian KiwiKilian changed the title Suggestion: Can we load up vite.config.js if it exits? Load vite.config.js for configuration Sep 8, 2024
@KiwiKilian KiwiKilian added the enhancement New feature or request label Sep 8, 2024
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

2 participants