Skip to content

Jacobs63/vite-laravel-valet-tls-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Vite plugin to easily handle Laravel Valet TLS sites

Latest Version on NPM Software License npm

The package contains a Vite plugin to easily handle Laravel Valet sites in Secure mode with TLS.

Installation

You can install the package via yarn:

yarn add vite-laravel-valet-tls-plugin

or npm:

npm install vite-laravel-valet-tls-plugin --save

Usage

Register the plugin in your vite config:

import laravelValetTlsPlugin from 'vite-laravel-valet-tls-plugin'

export default defineConfig({
    plugins: [
        //
        laravelValetTlsPlugin(),
        //
    ],
});

Make sure you specify your Valet app url in your .env:

MIX_APP_URL=http://my-app.test

Optionally, you could explicitly set the Valet app host when configuring the plugin:

import laravelValetTlsPlugin from 'vite-laravel-valet-tls-plugin'

export default defineConfig({
    plugins: [
        //
        laravelValetTlsPlugin({
            host: 'my-app.test'
        }),
        //
    ],
});

The plugin will now automatically handle the certificates for you whenever running Vite in development mode.

Credits

This package is based on an article by Freek from Spatie, which gave me an idea that this whole thing is possible.