Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mattltm's avatar

vendor:publish files not compiling with npm run dev

I've used php artisan vendor: publish spark-js to publish the spark files to /resources/assets/js/spark and i've edited register-stripe.js but the changes don't work when I run npm run dev.

Am I missing a step?

0 likes
8 replies
Nakov's avatar

Have you included the script in your webpack.js file?

mattltm's avatar

Do they not get included automatically when you run the vendor:publish command?

I've changed the js line in my webpack.mix.js file to:

.js(['resources/js/app.js','resources/assets/js/spark/auth/register-stripe.js'], 'public/js')

but it still doesn't work.

Nakov's avatar

When you changed it did you run npm run dev again?

They are not automatically included when you publish. Check your browser console for any errors. And app.js should be after the register-stripe.js script, in your webpack.

mattltm's avatar

It's very odd. It was working fine on my previous dev install without having to add anything to the webpack.mix.js file.

I'm running npm run dev after every change.

If I change the js line to:

.js(['resources/assets/js/spark/auth/register-stripe.js', 'resources/js/app.js'], 'public/js')

I get an error when loading the page about app.js being missing.

Nakov's avatar

Can you try instead of js to use scripts instead.

it might have worked in a previous project if you added the script in the HTML file in the head. But just by publishing won't work for sure..

mattltm's avatar

Nope, in my other VM (which I still have available) I just ran vendor:publish spark-js then I edited the files in resources/assets/js/spark, did npm run dev and everything worked.

I've compared the webpack.mix.js files and they are both the same. I have no idea what's different!

Nakov's avatar

@mattltm compare your main layout file. Or the pages that use the spark script. There you will find this

<script src="register-stripe.js"></script>

or something along those lines. Because until you have the JS file included on your page, there is no way just with vendor:publish to work.

mattltm's avatar

Thanks. I'll have another dig through my code!

Please or to participate in this conversation.