I had a strange thing pop up and I know this is an edge case. I've basically got a project where I needed to split out the front end so some very-non-technical people could do some HTML stuff.
I pulled out the webpack.mix.js file and I could not get everything to work. The folders were always wrong. That's when I noticed that there's a note in the mix api that states non-laravel proejcts need to use .setPublicPath(). I did that and everything is working and sure that's OK, but that's not what I want.
Now I have a webpack.mix file that differs by 1 line of code. I very much dislike this and before I go about trying to figure out how I can address this in my system I was wondering if anyone knows why this is the case?
How/Where/Why is mix doing something slightly different in a Laravel project vs a non-laravel project?
@joecianflone I don’t really know what it is you’re asking here. You need to set the public path in non-Laravel projects because you do.
Mix will do some sort of check to detect if it’s running in a Laravel project and set the public path accordingly. Outside of Laravel, you need to be explicit and tell Mix what you consider your “public” path and where you want built assets storing. That will also be the directory it stores the mix-manifest.json file in.
@martinbean it's the "because you do" part that I'm questioning or curious about. I have two projects with identical public folders but there's some check...somewhere in the laravel project that automatically sets the public path to public, but doesn't in non-laravel projects...why? Why not just have the default be public for non-laravel projects too?
This is not the right forum for this type of question...the right place would be in some sort of dev discussion, but the mix project doesn't have discussions turned on and it's not a bug so I'm not going to create an issue.
@joecianflone Like I say, it’ll use some sort of heuristic to check if it’s a Laravel project or not. It’s probably something as simple as checking a particular file exists at a particular location. I don’t know what; I don’t really want to dig into Mix’s source code to find out as it doesn’t bother me that much. You’re welcome to if you are that curious: https://github.com/JeffreyWay/laravel-mix