1

In prior versions of Laravel, I moved code with custom JS files into webpack.mix.js. Is there a way to make a similar one in Laravel 9, which uses vite.config.js?

mix.copy('resources/js/custom-file.js', 'public/js/').version();
1
  • why do not just use window.myfunction = myfunction in you custom-file.js and use @vite call in in your blade.php file… see stackoverflow.com/a/76712996/6614155 Commented Jul 18, 2023 at 13:02

2 Answers 2

0

I modified file vite.config.js:

import { viteStaticCopy } from 'vite-plugin-static-copy'

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

export default defineConfig({
    plugins: [


        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),



        viteStaticCopy({
            targets: [
                {
                    src: 'resources/js/feedback.js',
                    dest: 'js/custom.js'
                }
            ]
        })


    ],
});

That helped me with my issue...

Sign up to request clarification or add additional context in comments.

Comments

0

viteStaticCopy does not add entry in manifest.json

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.