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

Better vite.config handling #12

Open
YPetremann opened this issue Jun 4, 2022 · 0 comments
Open

Better vite.config handling #12

YPetremann opened this issue Jun 4, 2022 · 0 comments

Comments

@YPetremann
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch vite-plugin-restart@0.1.1 for the project I'm working on.

My project usually use multiple vite instance and therefore multiple vite config files, so I managed to automaticaly detect configFIle and then I've put a condition to prevent touching the file if it's vite config file.

Here is the diff that solved my problem:

diff --git a/node_modules/vite-plugin-restart/dist/index.js b/node_modules/vite-plugin-restart/dist/index.js
index 4410e6d..88311e8 100644
--- a/node_modules/vite-plugin-restart/dist/index.js
+++ b/node_modules/vite-plugin-restart/dist/index.js
@@ -146,8 +146,7 @@ function VitePluginRestart(options = {}) {
       c2.server.watch.disableGlobbing = false;
     },
     configResolved(config) {
-      if (import_fs.default.existsSync("vite.config.ts"))
-        configFile = "vite.config.ts";
+      configFile = config.configFile;
       root = config.root;
       restartGlobs = toArray(options.restart).map((i2) => import_path.default.posix.join(root, i2));
       reloadGlobs = toArray(options.reload).map((i2) => import_path.default.posix.join(root, i2));
@@ -161,6 +160,7 @@ function VitePluginRestart(options = {}) {
       server.watcher.on("change", handleFileChange);
       server.watcher.on("unlink", handleFileChange);
       function handleFileChange(file) {
+        if (file === configFile) return;
         if (import_micromatch.default.isMatch(file, restartGlobs)) {
           timerState = "restart";
           schedule(() => {

This issue body was partially generated by patch-package.

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

No branches or pull requests

1 participant