Support the ongoing development of Laravel.io →
JavaScript
0

I assume you mean with Vite?

If you want it to appear on all the same pages as app.js then import it in app.js

import './my-new.js';

Otherwise, add your script to vite.config.js

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js', 'resources/js/my-new.js'],
            refresh: true,
        }),
    ],
});

Then import it on specific pages/layouts in the <HEAD> section

@vite(['resources/css/app.css', 'resources/js/app.js', 'resources/js/my-new.js'])
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.