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

Allow root and outDir to be the same, if it's not the source file directory. #17725

Closed
4 tasks done
madsem opened this issue Jul 20, 2024 · 1 comment
Closed
4 tasks done

Comments

@madsem
Copy link

madsem commented Jul 20, 2024

Description

I'm seeing this warning:

(!) build.outDir must not be the same directory of root or a parent directory of root as this could cause Vite to overwriting source files with build outputs.

With a vite config like this:

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import vueDevTools from 'vite-plugin-vue-devtools';

export default defineConfig({
  root: path.resolve(__dirname, 'dist'),
  plugins: [vue(), vueDevTools()],
  build: {
    outDir: path.resolve(__dirname, 'dist'),
    emptyOutDir: true,
    rollupOptions: {
      input: {
        main: path.resolve(__dirname, 'dist/index.html'),
      },
    },
  },
  server: {
    open: true,
  },
});

The dist directory is dynamically built by a nodejs script, that copies files from different locations into the dist directory, to end up with a fully configured VueJS app. (Monorepo style)

Suggested solution

Maybe an additional config flag could be used to allow monorepo setups?
Or an option to suppress this warning?

I am unsure if my use case is common enough to even warrant this. If not please feel free to close :)

Alternative

No response

Additional context

No response

Validations

@bluwy
Copy link
Member

bluwy commented Jul 22, 2024

I think usecases like this is indeed rare and I think it's still useful to keep the warning in place. It can be dangerous too when having both the same value, especially in conjunction to emptyOutDir: true as you may be deleting your entire source code during build. I'll close this for now and a workaround if you need a different behaviour is probably fine for now.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants