Laravel Asset Helper
A VS Code extension for Laravel Blade theme assets.
When you install a pre-built HTML theme into a Laravel project, its assets often look like:
<link rel="stylesheet" href="/css/app.css">
<script src="js/app.js"></script>
Laravel expects public assets to be referenced with asset():
<link rel="stylesheet" href="{{ asset('client/css/app.css') }}">
<script src="{{ asset('client/js/app.js') }}"></script>
<img src="{{ asset('client/images/logo.svg') }}">
Usage
- Open a
.blade.php file.
- Open the VS Code Command Palette.
- Run Laravel Asset Helper: Link Theme Assets.
- Enter the public folder prefix.
For example, if your files are:
public/
└── client/
├── css/
├── js/
└── images/
enter:
client
If the assets are directly under public/, just press Enter without entering a prefix.
What it changes
The extension targets static asset attributes in:
<link href="...">
<script src="...">
<img src="https://github.com/Amirhossein-77/laravel-asset-helper/raw/HEAD/...">
<source src="...">
<video src="https://github.com/Amirhossein-77/laravel-asset-helper/raw/HEAD/...">
<video poster="...">
<audio src="...">
<track src="...">
<input src="...">
It intentionally does not rewrite normal <a href="..."> links because those are normally Laravel/application routes rather than static assets.
Ignored URLs
These are left unchanged:
http://...
https://...
//cdn.example.com/...
data:...
blob:...
mailto:...
tel:...
javascript:...
#...
- existing
asset(...) references
- Blade/PHP/expression-based values
- paths without a recognized static-asset extension
Development
npm install
npm run compile
To build a VSIX:
npm run package
Then install the generated .vsix through VS Code's Extensions: Install from VSIX... command.