So I want to be able to output files into other directories outside of the public path without changing it via mix.setPublicPath(). Not sure if it is currently possible but I did something similar using Laravel Elixir but now I am trying to move to Laravel Mix.
mix.standaloneSass('resources/assets/sass/example.scss', 'resources/assets/css');
mix.copy('resources/assets/css/example.css', 'resources/assets/css/test/second_example.css');
mix.styles(['resources/assets/css/example.css', 'resources/assets/css/test/second_example.css'], 'public/css').version();
@jeremy-smith-maco The second argument of most of the methods i think is the 'output path': https://github.com/JeffreyWay/laravel-mix/blob/master/docs/css-preprocessors.md https://github.com/JeffreyWay/laravel-mix/blob/master/docs/copying-files.md
@isaacesso Correct, but because the public path is automatically set to the 'public' folder in Laravel applications, the output folder can't be outside of the public folder for some reason.
@jeremy-smith-maco Yeah it's pretty weird! considering the fact that laravel mix is supposed to work with any non laravel project, all assets paths should indeed be relative to application root folder instead. I guess the only workaround now is the mix.setPublicPath() which seems a little awkward to me too.
You'd need to use mix.setPublicPath() to be explicit about where your public directory is.
It's not about where my public path is. It's about outputting a file to somewhere other than what the public path is specified to. Like my Laravel project has "Public" as the public folder which is where most of the files output to but I also need to output a couple of files to "Resources/Assets/*" but I can't do that. I tried setting the public path to the "Resources/Assets" folder and output there and then switch it back to "Public" but that didn't work. I could do this with Laravel Elixir but I can't seem to find a way to do it with Mix. @JeffreyWay
@jeremy-smith-maco You may try using mix.setPublicPath('./') , do not omit the . in front of /. It worked for me.
@isaacesso That does work for the output files, yes, but the mix-manifest.json is put in the project root folder but I want it inside of the Public folder.
@JeffreyWay
I need also this!
Pretty weird, having troubles doing this with .js files but .scss files work as intended using relative files.
Using mix.setPublicPath('./') and then build the paths as wanted does work but does leave the mix-manifest.json in root folder as @jeremy-smith-maco said
Most helpful comment
@isaacesso That does work for the output files, yes, but the
mix-manifest.jsonis put in the project root folder but I want it inside of thePublicfolder.