laravel / vite-plugin

Laravel plugin for Vite.
MIT License
810 stars 152 forks source link

Configurable assetUrl #270

Closed AmirHossein closed 11 months ago

AmirHossein commented 11 months ago

assetUrl uses env var but it would be great if we can pass it via config also. it required for asset cdn settings and css url() which is always relative. https://github.com/laravel/vite-plugin/blob/7abca675b82dd8a4fd23470f978110c3d083a0a1/src/index.ts#L132

Something like this:

const assetUrl = userConfig.assetUrl || (env.ASSET_URL ?? '');

and

export default defineConfig({
    assetUrl : 'https://cdn.com/assets/',
    plugins: [
        laravel({
            input: [
                // ...
            ],
            refresh: true,
        }),
    ],
});

and finally get compiled css like this:

@font-face{
    font-family:"FontName";
    font-style:normal;
    font-weight:400;
    font-display:block;
    src:url('https://cdn.com/assets/fa-brands-400.731b74d3.eot');
   /* ... */