npm i vite-plugin-query-string-versioning
import queryStringVersioning from 'vite-plugin-query-string-versioning';
export default {
plugins: [
queryStringVersioning()
]
};
When utilizing this plugin in Laravel, it's necessary to override the default Vite class to ensure proper detection of CSS files.
In bootstrap/app.php
register singleton:
->withSingletons([
Vite::class => fn() => new class extends Vite {
protected function isCssPath($path): bool
{
return Str::contains($path, '.css');
}
}
])
In AppServiceProvider.php
add the following to the register
method:
$this->app->singleton(
Vite::class,
fn() => new class extends Vite {
protected function isCssPath($path) {
return Str::contains($path, '.css');
}
}
);