Skip to content

avoid writing the temporary file when evaluating the config file #9470

@mihaon

Description

@mihaon

Description

I run vite inside a docker container for security reasons.

My docker run looks like:

docker container run -d --rm --name "myApp" \
	-v "~/myApp:/var/www/myApp:ro" \
	-v "~/myApp/tmp:/var/www/myApp/tmp:rw" \
	-v "~/myApp/logs:/var/www/myApp/logs:rw" \
	-v "~/myApp/package-lock.json:/var/www/myApp/package-lock.json:rw" \
	"myApp:latest"

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:

failed to load config from /var/www/myApp/vite.config.js
error during build:
Error: EROFS: read-only file system, open '/var/www/myApp/vite.config.js.timestamp-1659277944620.mjs'

Suggested solution

Write file only to explicitly set directories.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions