Laravel-mix: How do you output files outside of your public path without changing it?

Created on 30 Jun 2017  路  10Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 1.0.7
  • Node Version: 8.1.2
  • NPM Version: 5.0.4
  • OS: LMDE 2 Betsy

Description:

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.

Steps To Reproduce:

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();

Most helpful comment

@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.

All 10 comments

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bomavi picture Bomavi  路  3Comments

nezaboravi picture nezaboravi  路  3Comments

pixieaka picture pixieaka  路  3Comments

amin101 picture amin101  路  3Comments

wendt88 picture wendt88  路  3Comments