Skip to content

Automatically create hotFile parent directory #334

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

Merged
merged 4 commits into from
Jul 16, 2025

Conversation

adrum
Copy link
Contributor

@adrum adrum commented Jul 15, 2025

I have the following vite.config.ts:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import laravel from "laravel-vite-plugin";
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
    plugins: [
        tailwindcss(),
        laravel({
            input: ["src/App.tsx"],
            publicDirectory: "../wwwroot",
            hotFile: "../wwwroot/build/hot",
            refresh: true,
        }),
        react(),
    ],
    resolve: {
        alias: {
            "@": "/src",
        },
    },
    build: {
        emptyOutDir: true,
    },
});

When I run npm run dev on a fresh clone, I usually have to make the directory by hand. It would be nice if this library just did automatically.

@timacdonald timacdonald changed the base branch from 1.x to 2.x July 15, 2025 23:28
@timacdonald timacdonald force-pushed the feature/hotfile-directory-init branch from 74ac4af to 43359cc Compare July 15, 2025 23:34
@timacdonald
Copy link
Member

timacdonald commented Jul 16, 2025

Nice!

I added some logging when the directory is initially created, as I felt it would be easy to misconfigure the path with an absolute path and not realise where the hot file was written too, e.g., somewhere outside of the project directory on the system.

Screenshot 2025-07-16 at 10 17 15

src/index.ts Outdated
Comment on lines 220 to 222
setTimeout(() => {
server.config.logger.info(`${colors.green('laravel')} Hot file directory created ${colors.dim(fs.realpathSync(hotFileParentDirectory))}`, { clear: true, timestamp: true })
}, 200)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timeout is intentional to ensure our log appears after the initial Vite output. We use a similar technique below.

@adrum
Copy link
Contributor Author

adrum commented Jul 16, 2025

Looks great! Great idea @timacdonald

@taylorotwell taylorotwell merged commit 6774e33 into laravel:2.x Jul 16, 2025
3 checks passed
@adrum adrum deleted the feature/hotfile-directory-init branch July 17, 2025 00:09
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

Successfully merging this pull request may close these issues.

3 participants