avoid writing the temporary file when evaluating the config file
Problem
Description I run vite inside a docker container for security reasons. My `docker run` looks like: [code block] As you can see, the application code files are read-only and they can't be changed from inside the docker container (for example, some mistake like `rm -rf *` can't remove all my code files). But since version 3.0.1, `vite build` creates the `vite.config.js.mjs` file in the root directory, and since version 3.0.3 it creates a file with a random name like `vite.config.js.timestamp-1659277944620.mjs`. Because my application root is the read-only, then `docker container exec -i "myApp" bash -l -c 'npm run build'` fails with error: [code block] Suggested solution Write file only to explicitly set directories. Alternative _No response_ Additional context _No response_ Validations - [X] Follow our Code of Conduct - [X] Read the Contributing Guidelines. - [X] Read the docs. - [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Error Output
Error: EROFS: read-only file system, open '/var/www/myApp/vite.config.js.timestamp-1659277944620.mjs'
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: avoid writing the temporary file when evaluating the config file
These `vite.config.js.timestamp-1680094124134.mjs` files also cause race conditions with `make`'s dependency tracking because the file only exists momentarily and if it's removed after the `make` invocation, make will terminate with such errors: [code block] Can this file be removed or at least be moved to vite's temp dir `node_modules/.vite`?
Trust Score
6 verifications
- 1
These `vite.config.js.timestamp-1680094124134.mjs` files also cause race conditi
These `vite.config.js.timestamp-1680094124134.mjs` files also cause race conditions with `make`'s dependency tracking because the file only exists momentarily and if it's removed after the `make` invocation, make will terminate with such errors:
- 2
Can this file be removed or at least be moved to vite's temp dir `node_modules/.
Can this file be removed or at least be moved to vite's temp dir `node_modules/.vite`?
Validation
Resolved in vitejs/vite GitHub issue #9470. Community reactions: 17 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep